import '@/assets/taginput/jquery.tagsinput.css'
import '@/assets/taginput/jquery.tagsinput'
import pagination from '@/components/common/pageComponent'
import categoryComp from '@/pages/publish/EBayPublished/categoryComp.vue'
import instance from '@/api/index.js'
import baseURL from '@/js/common/baseURL'
import axios from 'axios'
import Vue from 'vue'

export default {
  name: "AddDraft",
  components: {
    pagination,
    categoryComp
  },
  data() {
    return {
      readOnly: false,//编辑或是查看
      imgList: [],
      images: [],
      items: ['111'],
      size: 0,
      shopList: [],//获取店铺列表
      siteList: [],//获取站点列表
      productList: [],//添加产品获取列表
      catorType: '',
      pages: {
        total: 0,
        current: 1,
        display: 10
      },
      productParams: {},//添加产品传参
      checkProduct: [],//选择产品
      addProductList: [],//添加产品
      attrProductList:[],//多属性添加产品
      ebaySku:'',//
      quoteSKU: '',
      generalInfo: {
        shop: '',//选择店铺
        shopName: '',//店铺名称
        site: '0',//选择站点
        sellWay: "FixedPriceItem",//刊登类型
        terrace: '',//平台sku
        upc: '',//upc
        isbn: '',//isbn
        ean: '',//ean
      },
      productAtt: {
        firstCator: '',//第一商品分类
        firstStor: '',//第一店铺分类
        firstCatorInfo: '',//第一商品分类信息
        firstStorInfo: '',//第一店铺分类信息
        secondCatorL: '',//第二商品分类
        secondCatorLInfo: '',//第二商品分类信息
        secondStor: '',//第二店铺分类
        secondStorInfo: '',//第二店铺分类信息
        catorType: '',//
        storckType: '',//
        storckOrCator: '',
        goodsState: [],//物品状况
        goodsStateSelect: '',
        properties: [],//物品属性
      },
      itemProperties: [{name: '', value: ''}],//物品属性
      titleAndPrice: {
        publishTitle: '',//刊登标题：
        publishsubhead: '',//刊登副标题
        units: "",//金额单位
        dateIssued: [],//上架时间
        dateIssuedSelect: 'Days_3',//上架时间选择
        startPrice: '',//起始价格,在竞拍时,传递该参数
        reservePrice: '',//保底价,在竞拍时,传递该参数
        fixedPrice: '',//一口价
        quantity: '',//数量
        inventoryWarning: '',//库存预警
        vatTaxRate: '',//vat税率
      },
      categoryLevelObj: {},//获取分类列表对象存值
      categoryLevelList: [],//获取分类列表存值
      categoryLevelListSave: [],
      findCategoryList: [],//查找类目集合
      findCategory: '',//查找类目
      activeIndex: null,
      selectedCategory: '',//已选类目
      selectedStor: '',//已选类目
      checkCategory: [],//分类选择
      checkCategoryId: '',//获取分类ID
      submintShow: false,
      categoryId: '',//分类ID
      categoryObj: {},//存分类对象
      categoryList: [],//存分类对象集合
      flag: false,
      myLen: 0,
      publishTitle: 80,
      publishsubhead: 80,
      maxstrlen: 80,
      errorShow: false,//错误显示
      errorMsg: '',//错误信息
      errorTitle: '',//错误提示标题
      errorClass: false,//错误样式
      multipleList: [],
      multipDefault: new Array(12),
      mulSetUp: [],//商品属性
      mulSetUpInput: '',//商品属性input输入框值
      properties: '',//添加属性项input输入框值
      propertiesList: [],//添加属性项集合
      focusState: false,//获取焦点
      attrTitle: '',//设置多属性信息标题
      attrInput: '',//设置多属性信息内容
      attrIndexP: 0,//设置多属性信息下标
      attrIndex: 0,//设置多属性信息下标
      multiattributeSetting: {//多属性信息
        UPCselect: 'UPC',
        num: '',//数量
        price: '',//价格
        UPC: '',//UPC
      },
      locationGood: {
        wareHouse: [],//仓库
        wareHouseSelect: '',//仓库选择
        whName: '',//仓库名称
        country: [],//国家
        countrySelect: '',//国家选择
        postcode: '',//邮编
      },//物品所在地
      logisticsSet: {
        domesticTransportType: [],//国内运输类型集合
        dttSelect: "Flat",//国内运输类型选择
        transportType: [],//运输类型
        transportTypeSelect: 'Flat',
        processingTime: '0',
        postcode: '',//邮编
        domesticServiceCharge: '',//国内手续费
        interCommission: '',//国际手续费
        interCommissionShow: false,
        dttSelectShow: false,//
        measurementUnit: 'English',//测量单位
        measurelbs: '',//估量单位
        measureoz: '',//估量单位
        size: '',//包裹大小
        sizeList: '',//包裹大小
        dimensionsLong: '',//尺寸规格
        dimensionsWide: '',//尺寸规格
        dimensionsHigh: '',//尺寸规格
        showlogistics: false,
        irregularShape: '',
      },
      intTransList: [],//国内运输方式
      inlandTransList: [],//国际运输方式
      intTransBoolean: false,//添加国内运输方式
      inlandTransBoolean: false,//添加国际运输方式

      internalTrans: {//国内
        transTypeIn: [],//第一运输方式
        transTypeInSelect: '',//第一运输方式选择
        freight: '',//运费
        extra: '',//额外没件加收
        extraCharge: '',//AK,HI,PR 额外收费
        freeShipping: false,
      },
      inlandTrans: {//国际
        transTypeIn: [],//第一运输方式
        transTypeInSelect: '',//第一运输方式选择
        freight: '',//运费
        extra: '',//额外没件加收
        shippingLocation: [],//获取运输地址--运输方式
        checkItems: [],//运输方式checkbox
        checkAllSL: false,//运输方式全选
        checkboxModel: [],//获取运输方式已选择
        freeShipping: false,
        global:''
      },
      modal: false,
      nonTransportArea: {//不送地区
        noTransArea: [],//获取不送地区列表
        nonTranSelect: '1',//选择不送下拉框
        noTransBoolean: false,//显示不送地区
        noTransChoose: [],//已选择不送地区
        domestic: [],
        international: [],
        additionalLocations: [],
        result: [],
        chooseNoTran: [],
        saveArr: [],
        saveToArr: [],
        allListCountry: []
      },
      payment: {//付款
        paymentMethod: [],//选择付款方式数组
        paypalcheckItems: ["PayPal"],//付款checked
        paypal: [],//paypal账号
        paypalSelect: '',//选择paypal
        paymentExplain: '',//付款说明
        paypalList: [],//获取paypal数据
        getPaypalList: false,//获取paypal
        paypalSelectShow: false,//paypal下拉框显示
        nopaypal: true,//没有paypal账号
      },
      tradeRestrictions: {//买卖限制
        hasAllow: 1,//是否允许卖家购买我的物品
        hasAllowBoolean: false,//显示是否允许卖家购买我的物品
        hasPayPal: '',//有没有PayPal账户
        hasPayPalMomt: '',//有没有PayPal账户选择
        shipToRegistrationCountry: '',//1:勾选“主要运送地址在我的运送范围之外” 0：没有勾选“主要运送地址在我的运送范围之外”
        shipToRegiCtrySelect: '',
        violateNum: [],//违反政策检举次数
        violateNumSelect: '',//违反政策检举次数选择
        violateTime: [],//违反政策检举时间范围
        violateTimeSelect: '',//违反政策检举时间范围选择
        astrictNum: [],//在过去10天内曾出价或购买我的物品，已达到我所设定的限制次数
        astrictNumSelect: '',//在过去10天内曾出价或购买我的物品，已达到我所设定的限制次数选择
        underCredit: [],//这项限制只适用于买家信用指数等于或低于这个值
        underCreditSelect: '',//这项限制只适用于买家信用指数等于或低于这个值选择
        nonPaymentNum: [],//未付款次数
        nonPaymentNumSelect: '',//未付款次数选择
        underBuyer: [],//这项限制只适用于买家信用指数等于或低于这个值
        underBuyerSelect: '',//这项限制只适用于买家信用指数等于或低于这个值
        underPeputation: [],//信用指标等于或低于这个值
        underPeputationSelect: -1//信用指标等于或低于这个值
      },
      describeInfo: {//描述信息
        goodsDescribe: '',//商品描述
      },
      salesReturn: {//退货政策
        policy: [],//获取退货政策数据
        policySelect: '',//选择退货政策
        days: [],//退货天数
        daysSelsct: '',//选择退货天数
        way: [],//退货方式
        waySelect: '',//选择退货方式
        principal: [],//退货运费由谁负担
        principalSelect: '',//选择退货运费由谁负担
        rateDepreciation: [],//折旧率
        rateDepSelect: '',//选择折旧率
        details: '',//退货政策详情
        show: true
      },
      dimension: {
        results: [],
        result: [],
      },

      allGlobbingarr: [],
      checkModel: '',
      noTranList: [],
      addNoTran: [],
      saveTranNo: [],
      attrSave: [],
      epsPeoduct: [],
      shippingServiceOptionList: [],
      publishId: '',
      show: false,//loading
      returnArr: [],
      getreturnArr: [],
      intTransListSave: [],//国内运输方式
      inlandTransListSave: [],//国际运输方式
      internalTransReturnArr: [],//国内运输方式
      inlandTransReturnArr: [],//国际运输方式
      internalTransReturnArr1: [],//国内运输方式
      inlandTransReturnArr1: [],//国际运输方式
      typeList: [],//获取产品标示类型
      currency: [],//获取货币
      active: 0,
      catorFilter: [],
      upToEbayFlag: false,
      processingTime: '0',//处理时间(工作日)
      dialogFormVisible: false,
      generalInfoId:'',
      firstCator:'',
      paypalSelect:'',
      chooseAttr:'',
      indexLn:0,
    }

  },
  directives: {
    focus: {
      // 当绑定元素插入到 DOM 中。
      inserted: function (el) {
        // 聚焦元素
        el.focus()
      }
    }
  },
  filters: {
    carriage: function (value) {
      let strIndex = '';
      switch (value) {
        case 0:
          strIndex = "一";
          break;
        case 1:
          strIndex = "二";
          break;
        case 2:
          strIndex = "三";
          break;
        case 3:
          strIndex = "四";
          break;
        case 4:
          strIndex = "五";
          break;
      }
      return strIndex;
    }
  },
  methods: {
    //过滤数据
    filterCator: function (_category, _search, _indexLn) {
      let vm = this;
      const categoryLevelListItem = vm.categoryLevelListSave[0].category;
      let arr = categoryLevelListItem;
      arr = arr.filter(function (item) {
        return (item['categoryName'].toLocaleLowerCase()).indexOf(_search.toLocaleLowerCase()) != -1;
      });
      vm.categoryLevelList[_indexLn].category = arr;
      console.log(arr)
      console.log(vm.categoryLevelList[_indexLn].category)
      console.log(vm.categoryLevelListSave[0].category)
    },
    // 获取分页
    pagechange: function (currentPage) {
      this.pages.current = currentPage;
      this.productParams.pages = currentPage;
      this.chooseProduct(this.chooseAttr,this.indexLn);
    },

    //获取路由
    getParams: function () {
      let routerParams = this.$route.query.draftId;
      let readOnly = this.$route.query.readOnly;
      this.readOnly = readOnly;
      return routerParams;
    },

    //选择产品
    chooseProduct: function (re,index) {
      let vm = this;
      vm.show = true;
      vm.checkProduct = [];
      vm.productParams.rows = 5;
      vm.productParams.name = '';
      vm.productParams.page = vm.pages.current;
      vm.pages.display = vm.productParams.rows;
      if (re == 'attr'){
        vm.chooseAttr = 'attr';
        vm.indexLn = index;
      } else {
        vm.chooseAttr = ''
      }
      console.log('vm.productParams',vm.productParams)
      instance({
        method: 'post',
        url: 'v1/goods/getList',
        params: vm.productParams
      }).then(function (data) {
        if (data.data.success) {
          vm.show = false;
          vm.productList = data.data.data.list;
          vm.pages.total = data.data.data.total;
        }
      });
    },
    // productPublish
    // productSKUPublish
    productPublish: function () {
      let vm = this;
      vm.show = true;
      this.active = 0;
      vm.checkProduct = [];
      vm.productParams.rows = 5;
      vm.productParams.page = vm.pages.current;
      vm.pages.display = vm.productParams.rows;
      instance({
        method: 'post',
        url: 'v1/goods/getList',
        params: vm.productParams
      }).then(function (data) {
        if (data.data.success) {
          vm.show = false;
          vm.productList = data.data.data.list;
          vm.pages.total = data.data.data.total;
        }
      });
    },

    productSKUPublish: function () {
      let vm = this;
      vm.show = true;
      this.active = 1;
      vm.checkProduct = [];
      vm.productParams.rows = 5;
      vm.productParams.page = vm.pages.current;
      vm.pages.display = vm.productParams.rows;
      instance({
        method: 'post',
        url: 'v1/goods/combination/getList',
        params: vm.productParams
      }).then(function (data) {
        if (data.data.success) {
          vm.show = false;
          vm.productList = data.data.data.list;
          vm.pages.total = data.data.data.total;
        }
      });
    },
    //定时信息提示
    setTime: function () {
      let vm = this;
      setTimeout(function () {
        vm.errorShow = false;
      }, 2500)
    },

    //关闭信息提示
    closeError: function () {
      this.errorShow = false;
    },

    //获取店铺列表
    getShopList: function () {
      let vm = this;
      instance.post('/v1/author/getAuthorShopList',{id: 1}).then(function (data) {
        console.log(data)
        if (data.data.success) {
          vm.shopList = data.data.data;
          console.log('vm.shopList',vm.shopList)
        }
      })
    },

    //获取站点列表
    getSiteList: function () {
      let vm = this;
      instance.post('/v1/ebay/meta/site/getList').then(function (data) {
        if (data.data.success) {
          vm.siteList = data.data.data;
          if (vm.generalInfo.site) {
            vm.getTime();
          }
        }
      })
    },

    //刊登类型
    chooseSellWay: function () {
      if (this.generalInfo.sellWay == 'FixedPriceItem') {
        this.titleAndPrice.fixedPrice = '';
        this.titleAndPrice.fixedPrice = '';
      }
      this.getTime();
    },

    //选择站点
    chooseSite: function () {
      this.getPayMentMethod();
      this.getTypeList();
      this.getCurrency();
    },

    //获取产品标示类型
    getTypeList: function () {
      let vm = this;
      if (vm.generalInfo.site) {
        instance({
          method: 'post',
          url: '/v1/ebay/meta/product/getTypeList',
          params: {
            siteId: vm.generalInfo.site,
          }
        }).then(function (data) {
          if (data.data.success) {
            vm.typeList = data.data.data;
            for (let ty = 0; ty < vm.typeList.length; ty++) {
              vm.typeList[ty].model = 'Does not apply';
            }
          }
        })
      }
    },
    //
    doesNot: function (_index) {
      Vue.set(this.typeList, _index, {
        model: "Does not apply",
        name: this.typeList[_index].name,
        code: this.typeList[_index].code
      })
    },

    // 获取货币
    getCurrency: function () {
      let vm = this;
      if (vm.generalInfo.site) {
        instance({
          method: 'post',
          url: '/v1/ebay/meta/currency/getTypeList',
          params: {
            siteId: vm.generalInfo.site,
          }
        }).then(function (data) {
          if (data.data.success) {
            vm.currency = data.data.data;
            vm.titleAndPrice.units = vm.currency[0].code;
            console.log(vm.currency)
          }
        })
      }
    },


    submitCategory: function () {
      let vm = this;
      if (!this.submintShow) {
        // vm.errorClass = false;
        // vm.errorShow = true;
        // vm.errorTitle = "类目选择错误";
        // vm.errorMsg = "请选择最后一级分类";
        vm.$message.error('请选择最后一级分类');
        // vm.setTime();
        return;
      }
      if (this.catorType == 1 && this.storckType == 0) {
        this.productAtt.firstCator = this.checkCategoryId;
        this.productAtt.firstCatorInfo = this.selectedCategory;
        this.getConditionValues();
        if (this.findCategoryList.length != 0) {
          this.productAtt.firstCator = this.categoryId;
        } else {
          this.categoryId = '';
        }
        this.getCategorySpecifics();
        this.getTime();
        this.getPayMentMethod();
      }
      if (this.catorType == 0 && this.storckType == 0) {
        this.productAtt.secondCatorL = this.checkCategoryId;
        this.productAtt.secondCatorLInfo = this.selectedCategory;
        if (this.findCategoryList.length != 0) {
          this.productAtt.secondCatorL = this.categoryId;
        } else {
          this.categoryId = '';
        }
      }
      if (this.catorType == 1 && this.storckType == 1) {
        this.productAtt.firstStor = this.checkCategoryId;
        this.productAtt.firstStorInfo = this.selectedCategory;
      }
      if (this.catorType == 0 && this.storckType == 1) {
        this.productAtt.secondStor = this.checkCategoryId;
        this.productAtt.secondStorInfo = this.selectedCategory;
      }
    },

    //
    handleChoose(row){
      if (!row.stockQty) {
        this.$message.error('当前产品库存为0，不能刊登！');
        this.checkProduct = [];
        this.checkProduct = Object.assign([],this.checkProduct)
      }
    },

    //保存选择的产品
    submitProduct: function () {
      if (this.checkProduct.length > 1 || this.checkProduct.length == 0) {
        // this.errorClass = false;
        // this.errorShow = true;
        // this.errorTitle = "操作失败";
        // this.errorMsg = "请选择一个产品";
        this.$message.error('请选择一个产品');
        // this.setTime();
        return;
      } else {
        if (this.chooseAttr == 'attr'){
          for (let i = 0; i < this.checkProduct.length; i++) {
            this.dimension.results[this.indexLn].ebaySku = this.checkProduct[i].sku;
          }
          Object.assign([],this.checkProduct)
          //   for (let i = 0; i < this.checkProduct.length; i++) {
          //   let attrMatchTag = true;
          //   for (let j = 0; j < this.attrProductList.length; j++) {
          //     let current = this.attrProductList[j];
          //     if (this.checkProduct[i].id == current.id) {
          //       attrMatchTag = false;
          //       break;
          //     }
          //
          //   }
          //   if (attrMatchTag) {
          //     this.attrProductList[0] = this.checkProduct[i];
          //     Object.assign([],this.attrProductList)
          //     this.ebaySku = this.attrProductList[0].sku;
          //   }
          // }
          // this.checkProduct = [];
        } else {
          // vm.indexLn
          for (let i = 0; i < this.checkProduct.length; i++) {
            let matchTag = true;
            for (let j = 0; j < this.addProductList.length; j++) {
              let current = this.addProductList[j];
              if (this.checkProduct[i].id == current.id) {
                matchTag = false;
                break;
              }

            }
            if (matchTag) {
              this.addProductList[0] = this.checkProduct[i];
            }
          }
          // this.generalInfo.sku = this.addProductList[0].sku;
          this.checkProduct = [];
        }
      }
    },

    quoteSystemSKU: function () {
      if (this.addProductList.length != 0) {
        this.quoteSKU = this.addProductList[0].sku;
      } else {
        // this.errorClass = false;
        // this.errorShow = true;
        // this.errorTitle = "引用系统SKU错误";
        // this.errorMsg = "请选择系统sku";
        // this.setTime();
        this.$message.error('请选择系统sku');
        return;
      }
    },

    //删除已选产品
    deleteProduct: function () {
      this.addProductList = [];
      this.generalInfo.sku = '';
    },

    //resetProdunt
    resetProdunt(){
      let vm = this;
      vm.checkProduct = [];
      vm.productParams.rows = 5;
      vm.productParams.name = '';
      vm.productParams.page = vm.pages.current;
      vm.pages.display = vm.productParams.rows;
      instance({
        method: 'post',
        url: 'v1/goods/getList',
        params: vm.productParams
      }).then(function (data) {
        if (data.data.success) {
          vm.show = false;
          vm.productList = data.data.data.list;
          vm.pages.total = data.data.data.total;
        }
      });
    },
    //
    searchP(){
      let vm = this;
      vm.checkProduct = [];
      vm.productParams.rows = 5;
      vm.productParams.page = vm.pages.current;
      vm.pages.display = vm.productParams.rows;
      var param = {
        rows: 5,
        page: vm.pages.current,
        name: vm.productParams.name,
        type: 4
      };
      instance({
        method: 'post',
        url: 'v1/goods/getList',
        // params: vm.productParams
        params: param
      }).then(function (data) {
        if (data.data.success) {
          vm.show = false;
          vm.productList = data.data.data.list;
          vm.pages.total = data.data.data.total;
        }
      });
    },

    //搜索eBay产品分类
    searchProduct: function (type, storRoCator) {
      let vm = this;
      this.categoryId = '';
      this.catorType = type;
      this.storckType = storRoCator;
      vm.selectedCategory = [];
      vm.checkCategory = [];
      vm.checkCategoryId = '';
      this.productAtt.storckOrCator = storRoCator;
      let url = '';
      if (storRoCator == 0) {
        url = 'v1/ebay/meta/category/getTopLevelList';
      } else {
        url = 'v1/ebay/meta/storeCategory/getTopLevelList'
      }
      vm.categoryLevelList = [];
      vm.categoryLevelListSave = [];
      vm.findCategoryList = [];
      vm.findCategory = "";
      vm.activeIndex = null;
      if (vm.generalInfo.site) {
        instance({
          method: 'post',
          url: url,
          params: {"siteId": vm.generalInfo.site}
        }).then(function (data) {
          if (data.data.success) {
            vm.categoryList = data.data.data;
            let categoryLevelObj = {};
            categoryLevelObj.category = vm.categoryList;
            categoryLevelObj.activeIndex = null;
            categoryLevelObj.search = null;
            vm.categoryLevelList.push(categoryLevelObj);
            vm.categoryLevelListSave.push(categoryLevelObj)
          }
        });
      } else {
        // vm.errorClass = false;
        // vm.errorShow = true;
        // vm.errorTitle = "操作失败";
        // vm.errorMsg = "请选择站点";
        // vm.setTime();
        vm.$message.error('请选择站点');
      }
    },

    //获取分类列表 - 选择父分类
    searchListByParentId: function (categoryActive, _category, index, active) {
      let parentId = _category.categoryId;
      let url = '';
      if (this.productAtt.storckOrCator == 0) {
        url = '/v1/ebay/meta/category/getListByParentId';
      } else {
        url = 'v1/ebay/meta/storeCategory/getListByParentId';
      }
      let vm = this;
      instance({
        method: 'post',
        url: url,
        params: {
          siteId: vm.generalInfo.site,
          categoryParentId: parentId
        }
      }).then(function (data) {
        let obj = {};
        obj.category = data.data.data;
        obj.activeIndex = null;

        if (_category.categoryLevel == vm.categoryLevelList.length && _category.leafCategory == 0) {
          vm.categoryLevelList.push(obj);
          vm.categoryLevelListSave.push(obj)
        }
        if (_category.categoryLevel != vm.categoryLevelList.length && _category.leafCategory == 0) {
          vm.categoryLevelList.splice((index + 2), (vm.categoryLevelList.length - (index + 2)));
          vm.categoryLevelList[vm.categoryLevelList.length - 1].category = data.data.data;
          vm.categoryLevelList[index + 1].activeIndex = null;
          vm.categoryLevelList[index + 1].search = null;
          vm.categoryLevelListSave.splice((index + 2), (vm.categoryLevelListSave.length - (index + 2)));
          vm.categoryLevelListSave[vm.categoryLevelListSave.length - 1].category = data.data.data;
          vm.categoryLevelListSave[index + 1].activeIndex = null;
          vm.categoryLevelListSave[index + 1].search = null;
        }
        if (_category.categoryLevel != vm.categoryLevelList.length && _category.leafCategory == 1) {
          vm.categoryLevelList.splice((index + 1), 1);
          vm.categoryLevelListSave.splice((index + 1), 1);
        }
        if (_category.categoryLevel == vm.categoryLevelList.length) {
          vm.submintShow = true;
        } else {
          vm.submintShow = false;
        }
        vm.checkCategory[index] = _category.categoryName;
        vm.checkCategoryId = _category.categoryId
        vm.selectedCategory = vm.checkCategory.join(" >> ");
      })

      categoryActive.activeIndex = active

    },

    //获取物品属性
    getCategorySpecifics: function () {
      let vm = this;
      instance({
        method: 'post',
        url: 'v1/ebay/categorySpecifics/getList',
        params: {
          siteId: vm.generalInfo.site,
          categoryId: vm.productAtt.firstCator
        }
      }).then(function (data) {
        console.log(data)
        if (data.data.success) {
          for (let i = 0; i < data.data.data.length; i++) {
            data.data.data[i].selectModal = '';
            data.data.data[i].selectChecked = [];
          }

          vm.productAtt.properties = data.data.data;
          console.log("before:", data);
          let _draftId = vm.getParams();
          if(_draftId && vm.firstCator == vm.productAtt.firstCator){
            var result = [];
            for (var i = 0; i < vm.productAtt.properties.length; i++) {
              var obj = vm.productAtt.properties[i];
              var num = obj.name;
              var isExist = false;
              for (var j = 0; j < vm.attrSave.length; j++) {
                var aj = vm.attrSave[j];
                var n = aj.name;
                if (n == num) {
                  isExist = true;
                  break;
                }
              }
              if (!isExist) {
                vm.itemProperties.push(obj);
              }
            }

          }else {
            vm.productAtt.goodsStateSelect= '';
            vm.itemProperties = [];
          }
          // for (let i = 0; i < vm.productAtt.properties.length; i++) {
          //   vm.productAtt.properties[i].selectModal = '';
          //   vm.productAtt.properties[i].selectChecked = [];
          // }
        }
      })
    },

    //添加自定物品属性
    addItemProperties: function () {
      let itemProperitesObj = {
        name: '',
        value: ''
      };
      this.itemProperties.push(itemProperitesObj);
    },

    //删除物品属性
    deleteAttr: function (_index) {
      this.itemProperties.splice(_index, 1);
    },

    //删除多属性
    deleteMultiattribute: function (_index) {
      this.dimension.results.splice(_index, 1);
    },

    //判断物品属性是否存在
    judgePepetition: function (_index) {
      for (let i = 0; i < this.productAtt.properties.length; i++) {
        if (this.itemProperties[_index].name.toLocaleLowerCase() == this.productAtt.properties[i].name.toLocaleLowerCase()) {
          // this.errorClass = false;
          // this.errorShow = true;
          // this.errorTitle = "商品属性名称检测";
          // this.errorMsg = "该商品属性名称【" + this.productAtt.properties[i].name + "】已存在";
          // this.itemProperties[_index].name = '';
          // this.setTime();
          this.$message.error("该商品属性名称【" + this.productAtt.properties[i].name + "】已存在");
        }
      }
      if (this.itemProperties.length > 1) {
        for (let j = 0; j < this.itemProperties.length; j++) {
          if (j == _index) {
            break;
          } else {
            if (this.itemProperties[_index].name == this.itemProperties[j].name) {
              // this.errorClass = false;
              // this.errorShow = true;
              // this.errorTitle = "商品属性名称检测";
              // this.errorMsg = "该商品属性名称【" + this.itemProperties[j].name + "】已存在";
              // this.itemProperties[_index].name = '';
              // this.setTime();
              this.$message.error("该商品属性名称【" + this.itemProperties[j].name + "】已存在");
            }
          }
        }
      } else {
        return;
      }
    },

    //查找类目
    findCategoryFm: function () {
      let vm = this;
      instance({
        method: 'post',
        url: '/v1/ebay/meta/category/getPathsByKeyword',
        params: {
          "siteId": vm.generalInfo.site,
          "keyword": vm.findCategory
        }
      }).then(function (data) {
        vm.findCategoryList = data.data.data
      })
    },

    //获取点击的类目
    chooseFindCategory: function (findCategory, id) {
      this.selectedCategory = findCategory;
      this.categoryId = id;
      this.submintShow = true;
    },

    //获取分类路径-输入分类ID
    getPath: function (type) {
      let vm = this;
      let _categoryId = '';
      if (type == 1) {
        _categoryId = vm.productAtt.firstCator
      } else {
        _categoryId = vm.productAtt.secondCatorL
      }
      if (!vm.generalInfo.site) {
        vm.$message.error("请选择站点");
      }
      instance({
        method: 'post',
        url: '/v1/ebay/meta/category/getPath',
        params: {
          siteId: vm.generalInfo.site,
          categoryId: _categoryId
        }
      }).then(function (data) {
        if (data.data.success) {
          if (type == 1) {
            vm.productAtt.firstCatorInfo = data.data.data;
            vm.getCategorySpecifics();
            vm.getConditionValues();
            vm.getPayMentMethod();
            vm.getTime();
          } else {
            vm.productAtt.secondCatorLInfo = data.data.data;
          }

        }
        if (!data.data.success && vm.productAtt.firstCator) {
          // vm.errorClass = false;
          // vm.errorShow = true;
          // vm.errorTitle = "操作失败";
          // vm.errorMsg = "分类ID不存在";
          // vm.setTime();
          vm.$message.error("分类ID不存在");
        }
        if (!data.data.success && vm.productAtt.secondCatorL) {
          // vm.errorClass = false;
          // vm.errorShow = true;
          // vm.errorTitle = "操作失败";
          // vm.errorMsg = "分类ID不存在";
          // vm.setTime();
          vm.$message.error("分类ID不存在");
        }
        // vm.selectedCategory = data.data.data
      })
    },

    //获取上架时间
    getTime: function () {
      let vm = this;
      if(!vm.productAtt.firstCator) return;
      instance({
        method: 'post',
        url: 'v1/ebay/meta/duration/getList',
        params: {
          siteId: vm.generalInfo.site,
          categoryId: vm.productAtt.firstCator,
          listingType: vm.generalInfo.sellWay
        }
      }).then(function (data) {
        if (data.data.success) {
          vm.titleAndPrice.dateIssued = data.data.data;
        }
      })
    },

    //商品图片选择
    multipleClick: function () {
      let vm = this;
      if (!this.quoteSKU){
        this.$message.error("请先输入平台SKU！");
      }
      if (!vm.generalInfo.site){
        vm.$message.error("请选择站点");
        return false
      }
      if (!vm.generalInfo.shop){
        vm.$message.error("请选择店铺");
        return false
      }
      if (!this.readOnly && this.quoteSKU) {
        document.getElementById('multiplePic').click();
      }
    },

    chooseMultipe: function (evt) {
      let files = evt.target.files;
      let vm = this;
      if (((files.length) + (vm.multipleList.length)) > 13) {
        vm.$message.error("最多只能选择12张图片");
        return false;
      }

      for (var i = 0; i < files.length; i++) {
        var reader = new FileReader();
        reader.readAsDataURL(files[i]);
        reader.onload = function (e) {
          // file.src = e.target.result
        };
        vm.epsPeoduct.push(files[i]);
        vm.doUpLoadFile(files[i])
      }
    },

    doUpLoadFile: function (_file) {
      let vm = this;
      let form = new FormData();
      form.append('file', _file, _file.name);
      form.append("key", vm.quoteSKU);
      form.append("type", "ebayItems");
      form.append("siteId", vm.generalInfo.site);
      form.append("shopId", vm.generalInfo.shop);
      axios({
        method: 'post',
        url: baseURL + '/v1/goods/uploadPic',
        headers: {
          'Content-Type': 'multipart/form-data'
        },
        data: form,
      }).then(function (data) {
        if (data.data.code == '9999' || data.data.code == '1111') {
          vm.$router.push({
            path: '/login',
          });
          return
        }
        if ( data.data.code == '0000') {
          vm.$router.push({
            path: '/notFound',
          });
          return
        }
        if (data.data.success) {
          let file = {};
          file.src = data.data.data;
          file.hasClass = true;
          file.noClass = false;
          vm.multipleList.push(file);
          vm.multipDefault.length = 12 - (vm.multipleList.length);
          // vm.selfUploadToeBay(_file,file)
        }
      })
    },

    selfUploadToeBay:function(_file,_data){
      let vm = this;
      let formEPS = new FormData();
      formEPS.append('files',  _file, _file.name);
      formEPS.append("ebaySku", vm.quoteSKU);
      formEPS.append("ossGoodsPicUrls",_data);
      formEPS.append("siteId", vm.generalInfo.site);
      formEPS.append("shopId", vm.generalInfo.shop);
      axios({
        method: 'post',
        url: baseURL + '/v1/ebay/uploadPicturesToEPS',
        headers: {
          'Content-Type': 'multipart/form-data'
        },
        data: formEPS
      }).then(function (data) {
        console.log(data)
        vm.upToEbayFlag = true;
        if (data.data.code == '9999') {
          vm.$router.push({
            path: '/login',
          });
          return
        }
        if ( data.data.code == '0000') {
          vm.$router.push({
            path: '/401',
          });
          return
        }
        if ( data.data.code == '1111') {
          vm.$router.push({
            path: '/401',
          });
          return
        }
        if (data.data.success) {
          vm.$message({
            message: '上传图片成功！',
            type: 'success'
          });
          vm.upToEbayFlag = data.data.success;
        }else {
          vm.$message.error('上传图片失败');
          return;
        }
      })
    },

    uploadToeBay: function () {
      let vm = this;
      if (vm.multipleList.length != 0) {
        if (vm.quoteSKU) {
          let arrPic = [];
          for (let ji = 0; ji < vm.multipleList.length; ji++) {
            arrPic.push(vm.multipleList[ji].src)
          }
          let form = new FormData();
          for (let ji = 0; ji < vm.epsPeoduct.length; ji++) {
            form.append('files', vm.epsPeoduct[ji], vm.epsPeoduct[ji].name);
            form.append("ebaySku", vm.quoteSKU);
            form.append("ossGoodsPicUrls", arrPic.join(','));
            form.append("siteId", vm.generalInfo.site);
            form.append("shopId", vm.generalInfo.shop);
          }
          axios({
            method: 'post',
            url: baseURL + '/v1/ebay/uploadPicturesToEPS',
            headers: {
              'Content-Type': 'multipart/form-data'
            },
            data: form
          }).then(function (data) {
            console.log(data)
            vm.upToEbayFlag = true;
            if (data.data.success) {
              vm.$message({
                message: '上传图片成功！',
                type: 'success'
              });
              vm.upToEbayFlag = data.data.success;
            }else {
              vm.$message.error('上传图片失败')
            }
          })
        } else {
          // vm.errorClass = false;
          // vm.errorShow = true;
          // vm.errorTitle = "操作失败";
          // vm.errorMsg = "请输入平台SKU";
          // vm.setTime();
          vm.$message.error("请输入平台SKU");
          return;
        }

      } else {
        // vm.errorClass = false;
        // vm.errorShow = true;
        // vm.errorTitle = "操作失败";
        // vm.errorMsg = "请选择商品图片";
        // vm.setTime();
        vm.$message.error("请选择商品图片");
      }
    },

    //选择运输类型
    chooseTranType: function () {
      if (this.logisticsSet.dttSelect == "Flat" && this.logisticsSet.transportTypeSelect == "Flat") {
        for (let key in this.logisticsSet) {
          this.logisticsSet[key] = "";
        }
        this.logisticsSet.dttSelect = "Flat";
        this.logisticsSet.transportTypeSelect = "Flat";
        this.logisticsSet.postcode = '';
        this.logisticsSet.domesticServiceCharge = '';
        this.logisticsSet.interCommission = '';
        this.logisticsSet.measurementUnit = '';
        this.logisticsSet.measurelbs = '';
        this.logisticsSet.measureoz = '';
        this.logisticsSet.size = '';
        this.logisticsSet.irregularShape = '';
        this.logisticsSet.dimensionsLong = '';
        this.logisticsSet.dimensionsWide = '';
        this.logisticsSet.dimensionsHigh = '';
      }
      // dttSelectShow
      if (this.logisticsSet.dttSelect == "Flat") {
        // domesticServiceCharge:'',//国内手续费
        //   interCommission:'',//国际手续费
        this.logisticsSet.domesticServiceCharge = '';
      }

      if (this.logisticsSet.transportTypeSelect == "Flat") {
        this.logisticsSet.interCommission = '';
      }
      this.getPackageSize();
    },


    //获取包裹大小
    getPackageSize: function () {
      let vm = this;
      instance({
        method: 'post',
        url: 'v1/ebay/meta/shippingPackage/getList',
        params: {
          siteId: vm.generalInfo.site,
        }
      }).then(function (data) {
        vm.logisticsSet.sizeList = data.data.data;
      })
    },


    itemClick: function (e) {
    },



    //删除图片
    deletePic: function (index) {
      $("#multiplePic").val("");
      this.multipleList.splice(index, 1);
      this.epsPeoduct.splice(index, 1);
      this.multipDefault.length = 12 - (this.multipleList.length);
    },

    //设为主题
    mainPic: function (index) {
      let firstProductPic = this.multipleList[0].src;
      let choosePic = this.multipleList[index].src;
      let temp = '';
      temp = firstProductPic;
      this.multipleList[0].src = this.multipleList[index].src;
      this.multipleList[index].src = temp;
    },

    //获取物品状况
    getConditionValues: function () {
      let vm = this;
      instance({
        method: 'post',
        url: 'v1/ebay/meta/conditionValues/getList',
        params: {
          siteId: 0,
          categoryId: vm.productAtt.firstCator
        }
      }).then(function (data) {
        if (data.data.success) {
          if (data.data.data.length == 0) {
            vm.productAtt.goodsStateSelect = '';
          }
          vm.productAtt.goodsState = data.data.data;
        }
      })
    },

    //返回类目
    backCategory: function () {
      this.findCategoryList = [];
      this.selectedCategory = '';
      this.findCategory = "";
      this.checkCategory = [];
    },

    //监听输入框的内容
    publishTitleFn: function (e, type) {
      this.myLen = 0;
      let str = $(e.target).val()
      this.getStrleng(str);
      if (this.myLen > this.maxstrlen) {
        if (parseInt(type) == 1) {
          this.titleAndPrice.publishTitle = str.substring(0, this.maxstrlen)
        } else if (parseInt(type) == 0) {
          this.titleAndPrice.publishsubhead = str.substring(0, this.maxstrlen)
        }
      } else {
        if (parseInt(type) == 1) {
          this.publishTitle = (this.maxstrlen) - this.myLen;
        } else if (parseInt(type) == 0) {
          this.publishsubhead = (this.maxstrlen) - this.myLen;
        }
      }
      if (this.myLen > this.maxstrlen && parseInt(type) == 1) {
        this.publishTitle = 0;
      } else if (this.myLen > this.maxstrlen && parseInt(type) == 0) {
        this.publishsubhead = 0;
      }
    },

    //添加商品属性
    addProducrAttru: function () {
      let producrAttru = {};
      if (this.mulSetUp.length >= 3) {
        // this.errorClass = false;
        // this.errorShow = true;
        // this.errorTitle = "操作失败";
        // this.errorMsg = "最多只能添加三条属性";
        // this.setTime();
        this.$message.error("最多只能添加三条属性");
        return
      }
      for (let i = 0; i < this.mulSetUp.length; i++) {
        if (this.mulSetUp[i].attr == this.mulSetUpInput) {
          // this.errorClass = false;
          // this.errorShow = true;
          // this.errorTitle = "操作失败";
          // this.errorMsg = "您输入的商品属性已经存在";
          // this.setTime();
          this.$message.error("您输入的商品属性已经存在");
          return;
        }
      }
      if (this.mulSetUpInput) {
        this.focusState = true;
        producrAttru.attr = this.mulSetUpInput;
        producrAttru.checked = this.mulSetUpInput;
        producrAttru.mulSetUpInput = '';
        producrAttru.attrArr = [];
        this.mulSetUp.push(producrAttru);
        this.mulSetUpInput = '';
      } else {
        // this.errorClass = false;
        // this.errorShow = true;
        // this.errorTitle = "操作失败";
        // this.errorMsg = "请输入商品属性";
        // this.setTime();
        this.$message.error("请输入商品属性");
      }
    },

    //添加自定义属性项
    addProperties: function (index) {
      if (!this.quoteSKU) {
        // this.errorClass = false;
        // this.errorShow = true;
        // this.errorTitle = "操作失败";
        // this.errorMsg = "请输入平台SKU";
        // this.setTime();
        this.$message.error("请输入平台SKU");
        return;
      }
      for (let i = 0; i < this.mulSetUp[index].attrArr.length; i++) {
        if (this.mulSetUp[index].attrArr[i].attr == this.mulSetUp[index].mulSetUpInput) {
          // this.errorClass = false;
          // this.errorShow = true;
          // this.errorTitle = "操作失败";
          // this.errorMsg = "请输入属性项已经存在";
          // this.setTime();
          this.$message.error("您输入属性项已经存在");
          return;
        }
      }
      if (this.mulSetUp[index].mulSetUpInput) {
        this.focusState = true;
        let _properties = "";
        let _propertiesObg = {};
        _propertiesObg.attr = this.mulSetUp[index].mulSetUpInput;
        _propertiesObg.checked = true;
        this.mulSetUp[index].attrArr.push(_propertiesObg);
        this.mulSetUp[index].mulSetUpInput = "";
        this.allGlobbingarr = [];
        let attrArr = [];
        for (let i = 0; i < this.mulSetUp.length; i++) {
          attrArr.push(this.mulSetUp[i].attrArr);
        }
        this.doCombinationCallback(attrArr)
      } else {
        // this.errorClass = false;
        // this.errorShow = true;
        // this.errorTitle = "操作失败";
        // this.errorMsg = "请输入属性项";
        // this.setTime();
        this.$message.error("请输入属性项");
      }
      $(".table-file").val("");
      this.checkModel = this.mulSetUp[0].attr;
      console.log(this.checkModel)
    },

    doCombination: function (arr, depth) {
      if (arr[depth].length != 0) {
        for (var i = 0; i < arr[depth].length; i++) {
          this.dimension.result[depth] = arr[depth][i].attr
          if (depth != arr.length - 1) {
            this.doCombination(arr, depth + 1)
          } else {
            let dimensionObj = {
              SKU: (this.quoteSKU) + '-' + (this.dimension.result.join('-')),
              num: '',
              ebaySku:'',
              price: '',
              UPC: 'Does not apply',
              // inputPic: '',
              pic: [],
            };
            this.dimension.results.push(dimensionObj);
          }
        }
      }
    },

    //获取多属性新信息
    getInfo: function (_obj, index, type) {
      this.modal = false;
      this.attrIndexP = index;
      if (type == 0) {
        this.attrTitle = '修改属性名称';
      } else {
        this.attrTitle = '修改属性项名称';
      }
      this.attrType = 1;
      this.attrInput = _obj;
    },

    //获取属性项信息
    getAttrInfo: function (_obj, index, indexP, type) {
      this.modal = false;
      this.attrIndex = index;
      this.attrIndexP = indexP;
      if (type == 0) {
        this.attrTitle = '修改属性名称';
      } else {
        this.attrTitle = '修改属性项名称';
      }
      this.attrType = 1;
      this.attrInput = _obj;
    },

    //删除属性项
    delAttrInfo: function (_obj, index, indexP, type) {
      delete this.mulSetUp[indexP].attrArr.splice(index, 1);
      let attrArr = [];
      for (let i = 0; i < this.mulSetUp.length; i++) {
        attrArr.push(this.mulSetUp[i].attrArr);
      }
      this.doCombinationCallback(attrArr);
    },

    //删除属性
    delMulSetUp: function (index) {
      delete this.mulSetUp.splice(index, 1);
      let attrArr = [];
      for (let i = 0; i < this.mulSetUp.length; i++) {
        attrArr.push(this.mulSetUp[i].attrArr);
      }
      this.doCombinationCallback(attrArr);
    },

    //保存修改后的数据
    saveAttr: function () {
      if (this.attrType == 0) {
        this.mulSetUp[this.attrIndexP].attr = this.attrInput;
      }
      if (this.attrType == 1) {
        for (let i = 0; i < this.mulSetUp[this.attrIndexP].attrArr.length; i++) {
          if (this.mulSetUp[this.attrIndexP].attrArr[i].attr == this.attrInput) {
            // this.errorClass = false;
            // this.errorShow = true;
            // this.errorTitle = "操作失败";
            // this.errorMsg = "请选择站点";
            // this.setTime();
            this.$message.error("请选择站点");
            return;
          } else {
            this.modal = true;
          }
        }
        this.mulSetUp[this.attrIndexP].attrArr[this.attrIndex].attr = this.attrInput;
        let attrArr = [];
        for (let i = 0; i < this.mulSetUp.length; i++) {
          attrArr.push(this.mulSetUp[i].attrArr);
        }
        this.doCombinationCallback(attrArr);
      }
    },


    //多属性批量设置
    ascertain: function (type) {
      // multiattributeSetting:{//多属性信息
      //   UPCselect:'UPC',
      //     num:'',//数量
      //     price:'',//价格
      //     UPC:'',//UPC
      // },

      for (let i = 0; i < this.dimension.results.length; i++) {
        if (type == 1) {
          this.dimension.results[i].num = this.multiattributeSetting.num;
        }
        if (type == 2) {
          this.dimension.results[i].price = this.multiattributeSetting.price;
        }
        if (type == 3) {
          this.dimension.results[i].UPC = this.multiattributeSetting.UPC;
        }
      }
    },

    doCombinationCallback: function (arr) {
      this.dimension.results = [];
      this.dimension.result = [];
      this.doCombination(arr, 0);
      // this.dimension.results;
    },


    //获取仓库地址
    getWareHours: function () {
      let vm = this;
      instance({
        method: 'post',
        url: '/v1/warehouse/getUserWareHouseList',
      }).then(function (data) {
        if (data.data.success) {
          vm.locationGood.wareHouse = data.data.data;
        }
      })
    },

    chooseWareHours: function (id) {
      this.locationGood.whName = this.locationGood.wareHouse.find(item => item.id === id)['name'];
    },

    //获取国家信息
    getCountry: function () {
      let vm = this;
      instance({
        method: 'post',
        url: 'v1/ebay/meta/country/getList',
      }).then(function (data) {
        if (data.data.success) {
          vm.locationGood.country = data.data.data;
        }
      })
    },

    //选择不规则形状
    // chooseIrregularShape: function () {
    //   if (this.logisticsSet.irregularShape) {
    //     this.logisticsSet.irregularShapeChoose = 0;
    //   } else {
    //     this.logisticsSet.irregularShapeChoose = 1;
    //   }
    // },
    returnTransTypeFn: function (_internat) {
      let vm = this;
      vm.returnArr = [];
      if (!vm.generalInfo.site) {
        // this.errorClass = false;
        // this.errorShow = true;
        // this.errorTitle = "操作失败";
        // this.errorMsg = "请选择站点";
        // this.setTime();
        this.$message.error("请选择站点");
        return;
      }
      instance({
        method: "post",
        url: 'v1/ebay/meta/shippingService/getList',
        params: {
          siteId: vm.generalInfo.site,
          internationalService: _internat
        }
      }).then(function (data) {
        if (data.data.success) {
          let arrTrans = data.data.data;
          let arr1 = [];
          vm.returnArr = [];
          for (let i = 0; i < arrTrans.length; i++) {
            arr1.push(arrTrans[i]['shippingCategory']);
          }
          var result = vm.res(arr1);
          for (let i = 0; i < result.length; i++) {
            let arr = [];
            let arrTransObj = {
              arrTran: [],
              shippingCategory: ''
            };
            for (let j = 0; j < arrTrans.length; j++) {
              if (result[i] && arrTrans[j]['shippingCategory']) {
                if (result[i] == arrTrans[j]['shippingCategory']) {
                  arr.push(arrTrans[j]);
                  arrTransObj.arrTran = arr;
                  arrTransObj.shippingCategory = arrTrans[j]['shippingCategory'];
                }
              } else {
                return;
              }
            }
            if (_internat == 0) {
              vm.internalTransReturnArr.push(arrTransObj);
            } else {
              vm.inlandTransReturnArr.push(arrTransObj);
            }
          }
          if (_internat == 0) {
            for (let kj = 0; kj < vm.shippingServiceOptionList.length; kj++) {
              if (vm.shippingServiceOptionList[kj].internationalService == 0) {

                // vm.logisticsSet.processingTime = vm.shippingServiceOptionList[kj].shippingServicePriority;
                vm.internalTrans = {
                  transTypeIn: vm.internalTransReturnArr,
                  shippingServicePriority: kj + 1,
                  transTypeInSelect: vm.shippingServiceOptionList[kj].shippingService,//第一运输方式选择
                  freight: vm.shippingServiceOptionList[kj].shippingServiceCost,//运费
                  extra: vm.shippingServiceOptionList[kj].shippingServiceAdditionalCost,//额外没件加收
                  extraCharge: vm.shippingServiceOptionList[kj].shippingSurcharge,//AK,HI,PR 额外收费
                  freeShipping: vm.shippingServiceOptionList[kj].freeShipping == 0 ? false : true,//免费
                };
                vm.intTransList.push(vm.internalTrans)
              }
            }
          } else {
            for (let kj = 0; kj < vm.shippingServiceOptionList.length; kj++) {
              if (vm.shippingServiceOptionList[kj].internationalService == 1) {
                let arrTranList = vm.shippingServiceOptionList[kj].shipToLocation.split(',');
                let arrObj = [];
                for (let tr = 0; tr < arrTranList.length-1; tr++) {
                  let arrTranListObj = {};
                  arrTranListObj.value = arrTranList[tr];
                  arrObj.push(arrTranListObj)
                }

                vm.inlandTrans = {
                  transTypeIn: vm.inlandTransReturnArr,//第一运输方式
                  transTypeInSelect: vm.shippingServiceOptionList[kj].shippingService,//第一运输方式选择
                  freight: vm.shippingServiceOptionList[kj].shippingServiceCost,//运费
                  extra: vm.shippingServiceOptionList[kj].shippingServiceAdditionalCost,//额外没件加收
                  shippingLocation: vm.inlandTrans.shippingLocation,//获取运输地址--运输方式
                  shippingServicePriority: kj + 1,
                  checkItems: arrObj,//运输方式checkbox
                  checkboxModel: [],//获取运输方式已选择
                  freeShipping: vm.shippingServiceOptionList[kj].freeShipping == 0 ? false : true,//免费
                  global:''
                };
                if(arrObj.length == vm.inlandTrans.shippingLocation.length){
                  vm.inlandTrans.checkAllSL = true;
                  vm.inlandTrans.global = "1";
                }else {
                  vm.inlandTrans.checkAllSL = false;
                  vm.inlandTrans.global = "2";
                }
                console.log('vm.inlandTrans.shippingLocation',vm.inlandTrans.shippingLocation)
                vm.inlandTransList.push(vm.inlandTrans)
                console.log(vm.inlandTransList)
              }
            }
          }

        }
      })
    },

    freeShippingFn: function (_item) {
      if (_item.freeShipping) {
        _item.freight = 0;
      } else {
        _item.freight = '';
      }
    },

    //
    changeTypeTran: function (_item, _type, _changeitem) {
      let vm = this;
      let internationalService = 0;
      if (_type == 0) {
        internationalService = 0;
      } else {
        internationalService = 1;
      }
      instance({
        method: 'post',
        url: 'v1/ebay/meta/shippingService/getList',
        params: {
          siteId: vm.generalInfo.site,
          internationalService: internationalService
        }
      }).then(function (data) {
        if (data.data.success) {
          let arrTransChoose = data.data.data;
          console.log('运输服务选择', arrTransChoose)
          for (let tran = 0; tran < arrTransChoose.length; tran++) {
            if (arrTransChoose[tran].shippingService == _item) {
              if (arrTransChoose[tran].surchargeApplicable == 0) {
                _changeitem.extraCharge = null;
              } else {
                _changeitem.extraCharge = '';
              }
              if (arrTransChoose[tran].serviceType.indexOf(vm.logisticsSet.dttSelect) == -1 && _type == 0) {
                vm.logisticsSet.dttSelect = 'Flat';
                // vm.errorClass = false;
                // vm.errorShow = true;
                // vm.errorTitle = "国内运输方式选择提示";
                // vm.errorMsg = "_抱歉，所选运输方式不支持 国内 运输类型为计算";
                // vm.setTime();
                vm.$message.error("抱歉，所选运输方式不支持 国内 运输类型为计算");
              }
              if (arrTransChoose[tran].serviceType.indexOf(vm.logisticsSet.transportTypeSelect) == -1 && _type == 1) {
                vm.logisticsSet.transportTypeSelect = 'Flat';
                // vm.errorClass = false;
                // vm.errorShow = true;
                // vm.errorTitle = "国际运输方式选择提示";
                // vm.errorMsg = "_抱歉，所选运输方式不支持 国际 运输类型为计算";
                // vm.setTime();
                vm.$message.error("抱歉，所选运输方式不支持 国际 运输类型为计算");
              }
            }
          }
        }
      });
      // Calculated
    },

    //添加运输方式
    addTransTypeFn: function (_internat) {
      let vm = this;
      if (_internat == 0) {
        vm.internalTrans.transTypeIn = [];
      } else {
        vm.inlandTrans.transTypeIn = [];
      }
      if (!vm.generalInfo.site) {
        // this.errorClass = false;
        // this.errorShow = true;
        // this.errorTitle = "操作失败";
        // this.errorMsg = "请选择站点";
        // this.setTime();
        this.$message.error("请选择站点");
        return;
      }
      instance({
        method: "post",
        url: 'v1/ebay/meta/shippingService/getList',
        params: {
          siteId: vm.generalInfo.site,
          internationalService: _internat
        }
      }).then(function (data) {
        console.log(data)
        if (data.data.success) {
          let arrTrans = data.data.data;
          let arr1 = [];
          for (let i = 0; i < arrTrans.length; i++) {
            arr1.push(arrTrans[i]['shippingCategory']);
          }
          var result = vm.res(arr1);
          // vm.internalTrans.transTypeIn = vm.res(arrTrans);
          for (let i = 0; i < result.length; i++) {
            let arr = [];
            let arrTransObj = {
              arrTran: [],
              shippingCategory: ''
            };
            for (let j = 0; j < arrTrans.length; j++) {
              if (result[i] && arrTrans[j]['shippingCategory']) {
                if (result[i] == arrTrans[j]['shippingCategory']) {
                  arr.push(arrTrans[j]);
                  arrTransObj.arrTran = arr;
                  arrTransObj.shippingCategory = arrTrans[j]['shippingCategory'];
                }
              } else {
                return;
              }
            }
            if (_internat == 0) {
              vm.internalTrans.transTypeIn.push(arrTransObj)
            } else {
              vm.inlandTrans.transTypeIn.push(arrTransObj)
            }
          }
          vm.internalTrans = {
            transTypeIn: vm.internalTrans.transTypeIn,
            transTypeInSelect: '',//第一运输方式选择
            freight: '',//运费
            extra: '',//额外没件加收
            extraCharge: '',//AK,HI,PR 额外收费
            freeShipping: false,//免费
          };
          vm.inlandTrans = {
            transTypeIn: vm.inlandTrans.transTypeIn,//第一运输方式
            transTypeInSelect: '',//第一运输方式选择
            freight: '',//运费
            extra: '',//额外没件加收
            shippingLocation: vm.inlandTrans.shippingLocation,//获取运输地址--运输方式
            checkItems: [],//运输方式checkbox
            checkAllSL: false,//运输方式全选
            checkboxModel: [],//获取运输方式已选择
            freeShipping: false,//免费
            global:''
          };
          if (_internat == 0) {
            vm.intTransList.push(vm.internalTrans);
          } else {
            vm.inlandTransList.push(vm.inlandTrans);
            vm.getShipLocal();
          }
        }

      })
    },

    addTransListFn: function (_internat) {
      let vm = this;
      if (_internat == 0) {
        this.internalTrans = {
          transTypeIn: this.internalTrans.transTypeIn,
          transTypeInSelect: '',//第一运输方式选择
          freight: '',//运费
          extra: '',//额外没件加收
          extraCharge: '',//AK,HI,PR 额外收费
          freeShipping: false,
        };
        if (this.intTransList.length > 4) {
          // this.errorClass = false;
          // this.errorShow = true;
          // this.errorTitle = "不能添加";
          // this.errorMsg = "抱歉，运输方式最多添加5项";
          // this.setTime();
          this.$message.error("抱歉，运输方式最多添加5项");
          return;
        } else {
          this.intTransList.push(this.internalTrans);
        }
      } else {
        this.inlandTrans = {
          transTypeIn: this.inlandTrans.transTypeIn,//第一运输方式
          transTypeInSelect: '',//第一运输方式选择
          freight: '',//运费
          extra: '',//额外没件加收
          shippingLocation: this.inlandTrans.shippingLocation,//获取运输地址--运输方式
          checkItems: [],//运输方式checkbox
          checkAllSL: false,//运输方式全选
          checkboxModel: [],//获取运输方式已选择
          freeShipping: false,
          global:''
        };
        if (this.inlandTransList.length > 4) {
          // this.errorClass = false;
          // this.errorShow = true;
          // this.errorTitle = "不能添加";
          // this.errorMsg = "抱歉，运输方式最多添加5项";
          // this.setTime();
          this.$message.error("抱歉，运输方式最多添加5项");
          return;
        } else {
          this.inlandTransList.push(this.inlandTrans);
        }
      }

    },

    //删除运输方式
    deleteTran: function (index, _internat) {
      if (_internat == 0) {
        this.intTransList.splice(index, 1);
      }
      if (_internat == 1) {
        this.inlandTransList.splice(parseInt(index), 1);
      }
    },

    //选出重复运输方式；
    res: function (arr) {
      let tmp = [];
      arr.sort().sort(function (a, b) {
        if (a.shippingCategory == b.shippingCategory && tmp.indexOf(a) === -1) {
          tmp.push(a)
        }
      })
      return tmp;
    },

    //获取运输地址
    getShipLocal: function () {
      let vm = this;
      vm.inlandTrans.shippingLocation = [];
      instance({
        method: 'post',
        url: 'v1/ebay/meta/shippingLocation/getCodeList',
        params: {
          siteId: vm.generalInfo.site,
        }
      }).then(function (data) {
        if (data.data.success) {
          let inShip = data.data.data;
          // vm.inlandTrans.shippingLocation = data.data.data;
          for (let i = 0; i < inShip.length; i++) {
            let inShipObg = {};
            inShipObg.value = inShip[i];
            vm.inlandTrans.shippingLocation.push(inShipObg);
          }
        }
      })
    },

    //运输地区全选
    checkAllShipLocal: function (index) {
      var vm = this;
      if (vm.inlandTransList[index].checkAllSL) {
        vm.inlandTransList[index].checkItems = [];
      } else {
        vm.inlandTransList[index].shippingLocation.forEach(function (item) {
          let itemObj = {};
          itemObj.value = item.value;
          vm.inlandTransList[index].checkItems.push(itemObj);
        });
      }
    },

    //全球选择
    checkAllglobal: function (index) {
      var vm = this;
      vm.inlandTransList[index].checkAllSL = true;
      vm.inlandTransList[index].shippingLocation.forEach(function (item) {
        let itemObj = {};
        itemObj.value = item.value;
        vm.inlandTransList[index].checkItems.push(itemObj);
      });
    },

    //部分国家
    checkAllPart: function (index) {
      let vm = this;
      vm.inlandTransList[index].checkItems = [];
      vm.inlandTransList[index].checkAllSL = false;
    },

    //验证只能输入数字
    clearNoNum: function (obj) {
      //先把非数字的都替换掉，除了数字和.
      // if (obj) {
      //   if (!obj.replace(/[^\d.]/g, "")) {
      //     // this.errorClass = false;
      //     // this.errorShow = true;
      //     // this.errorTitle = "操作失败";
      //     // this.errorMsg = "请输入数字";
      //     // this.setTime();
      //     this.$message.error("请输入数字");
      //   }
      // }
    },

    //选择不送地区
    chooseNoTransArea: function () {
      let vm = this;
      if (vm.nonTransportArea.nonTranSelect == "2") {
        vm.nonTransportArea.noTransBoolean = true;
      } else {
        vm.nonTransportArea.noTransBoolean = false;
      }
    },

    //创建不送地区列表
    createNoTrans: function () {
      let vm = this;
      this.nonTransportArea.chooseNoTran = this.nonTransportArea.noTransChoose;
      vm.nonTransportArea.noTransArea = [];
      let noTransStr = 'Additional Locations,Worldwide,Domestic Location';
      instance({
        method: 'post',
        url: 'v1/ebay/meta/excludeShippingLocation/getList',
        params: {
          siteId: vm.generalInfo.site,
          regions: noTransStr
        }
      }).then(function (data) {
        if (data.data.success) {
          let noTransList = data.data.data;
          let list = [];
          for (let i = 0; i < noTransList.length; i++) {
            list.push(noTransList[i]['region'])
          }
          let temp = vm.res(list);
          for (let j = 0; j < temp.length; j++) {
            let arr = [];
            let noTransObj = {
              children: [],
              region: '',
            };
            for (let k = 0; k < noTransList.length; k++) {
              if (temp[j] == noTransList[k]['region']) {
                arr.push(noTransList[k]);
                noTransObj.children = arr;
                for (let n = 0; n < noTransObj.children.length; n++) {
                  noTransObj.children[n].active = false;
                  noTransObj.children[n].childrenCountry = []
                  noTransObj.children[n].checkModalCountry = [];
                }
                noTransObj.checkModal = [];
                noTransObj.region = noTransList[k]['region'];
              }
            }
            vm.nonTransportArea.noTransArea.push(noTransObj);
          }
          if (vm.nonTransportArea.noTransChoose.length != 0) {
            for (let io = 0; io < vm.nonTransportArea.noTransChoose.length; io++) {
              for (let ui = 0; ui < vm.nonTransportArea.noTransArea.length; ui++) {
                for (let yy = 0; yy < vm.nonTransportArea.noTransArea[ui].children.length; yy++) {
                  if (vm.nonTransportArea.noTransChoose[io] == vm.nonTransportArea.noTransArea[ui].children[yy].description) {
                    vm.nonTransportArea.noTransArea[ui].checkModal.push(vm.nonTransportArea.noTransChoose[io]);
                  }
                }
              }
            }

            for (let io = 0; io < vm.nonTransportArea.noTransChoose.length; io++) {
              for (let ui = 0; ui < vm.nonTransportArea.noTransArea.length; ui++) {
                for (let yy = 0; yy < vm.nonTransportArea.noTransArea[ui].children.length; yy++) {
                  for (let hh = 0; hh < vm.nonTransportArea.noTransArea[ui].children[yy].childrenCountry; hh++) {
                    if (vm.nonTransportArea.noTransChoose[io] == vm.nonTransportArea.noTransArea[ui].children[yy].checkModalCountry[hh].description) {
                      vm.nonTransportArea.noTransArea[ui].children[yy].checkModalCountry.push(vm.nonTransportArea.noTransChoose[io]);
                    }
                  }
                }
              }
            }
          }
        }
      })
    },

    //获取洲信息
    chooseCountry: function (_noTranItemList, _indexPar, _indexChild) {
      let vm = this;
      instance({
        method: 'post',
        url: 'v1/ebay/meta/excludeShippingLocation/getList',
        params: {
          siteId: vm.generalInfo.site,
          regions: _noTranItemList.location
        }
      }).then(function (data) {
        _noTranItemList.childrenCountry = data.data.data;
        vm.nonTransportArea.chooseNoTran = [];
        for (let ii = 0; ii < vm.nonTransportArea.noTransArea.length; ii++) {
          vm.nonTransportArea.chooseNoTran = vm.nonTransportArea.chooseNoTran.concat(vm.nonTransportArea.noTransArea[ii].checkModal);
        }

        if (vm.nonTransportArea.noTransArea[_indexPar].checkModal.indexOf(_noTranItemList.description) > -1) {
          _noTranItemList.checkModalCountry = [];
          for (let jj = 0; jj < _noTranItemList.childrenCountry.length; jj++) {
            _noTranItemList.checkModalCountry.push(_noTranItemList.childrenCountry[jj].description);
          }
        } else {
          _noTranItemList.checkModalCountry = [];
        }
        let arrList = [];
        let noTranList = [];
        for (let i = 0; i < vm.nonTransportArea.noTransArea.length; i++) {
          arrList = arrList.concat(vm.nonTransportArea.noTransArea[i].checkModal);
          for (let jm = 0; jm < vm.nonTransportArea.noTransArea[i].children.length; jm++) {
            let len = vm.nonTransportArea.noTransArea[i].children[jm].childrenCountry.length;
            let lenCheck = vm.nonTransportArea.noTransArea[i].children[jm].checkModalCountry.length;
            if (len == lenCheck && lenCheck != 0) {
              // break;
            } else {
              noTranList = noTranList.concat(vm.nonTransportArea.noTransArea[i].children[jm].checkModalCountry);
            }
          }
        }
        vm.nonTransportArea.chooseNoTran = vm.unique(noTranList.concat(arrList));
      });
    },

    //显示国家
    showCountry: function (_noTranItem, _indexPar, _indexChild) {
      let vm = this;
      instance({
        method: 'post',
        url: 'v1/ebay/meta/excludeShippingLocation/getList',
        params: {
          siteId: vm.generalInfo.site,
          regions: _noTranItem.location
        }
      }).then(function (data) {
        if (data.data.success) {
          _noTranItem.childrenCountry = data.data.data;
          _noTranItem.active = !_noTranItem.active;
          if (_noTranItem.active) {
            for (let tr = 0; tr < vm.nonTransportArea.chooseNoTran.length; tr++) {
              for (let er = 0; er < _noTranItem.childrenCountry.length; er++) {
                if (_noTranItem.childrenCountry[er].description == vm.nonTransportArea.chooseNoTran[tr]) {
                  _noTranItem.checkModalCountry.push(vm.nonTransportArea.chooseNoTran[tr]);
                }
              }
            }
            for (let cp = 0; cp < vm.nonTransportArea.chooseNoTran.length; cp++) {
              if (_noTranItem.description == vm.nonTransportArea.chooseNoTran[cp]) {
                for (let yu = 0; yu < _noTranItem.childrenCountry.length; yu++) {
                  _noTranItem.checkModalCountry.push(_noTranItem.childrenCountry[yu].description);
                  _noTranItem.checkModalCountry = vm.unique(_noTranItem.checkModalCountry);
                }
              }
            }
            let arrList = [];
            let noTranList = [];
            vm.nonTransportArea.chooseNoTran = [];
            for (let i = 0; i < vm.nonTransportArea.noTransArea.length; i++) {
              arrList = arrList.concat(vm.nonTransportArea.noTransArea[i].checkModal);
              for (let jm = 0; jm < vm.nonTransportArea.noTransArea[i].children.length; jm++) {
                let len = vm.nonTransportArea.noTransArea[i].children[jm].childrenCountry.length;
                let lenCheck = vm.nonTransportArea.noTransArea[i].children[jm].checkModalCountry.length;
                if (len == lenCheck && lenCheck != 0) {
                  // break;
                } else {
                  noTranList = noTranList.concat(vm.nonTransportArea.noTransArea[i].children[jm].checkModalCountry);
                }
              }
            }
            vm.nonTransportArea.chooseNoTran = vm.unique(noTranList.concat(arrList));
          }
        }
      })
    },

    //国家
    countryItem: function (_noTranItemCountry, _noTranItemListItem, _indexPar, _indexChild) {
      let vm = this;
      let noTranChild = _noTranItemCountry.childrenCountry.length;
      let noTranChcheck = _noTranItemCountry.checkModalCountry.length;
      if (noTranChild == noTranChcheck && noTranChcheck != 0) {
        vm.nonTransportArea.noTransArea[_indexPar].checkModal.push(_noTranItemCountry.description);
      } else {
        if (vm.nonTransportArea.noTransArea[_indexPar].checkModal.indexOf(_noTranItemCountry.description) > -1) {
          vm.nonTransportArea.noTransArea[_indexPar].checkModal.splice(vm.nonTransportArea.noTransArea[_indexPar].checkModal.indexOf(_noTranItemCountry.description), 1)
        }
      }
      let arrList = [];
      let noTranList = [];
      for (let i = 0; i < vm.nonTransportArea.noTransArea.length; i++) {
        arrList = arrList.concat(vm.nonTransportArea.noTransArea[i].checkModal);
        for (let jm = 0; jm < vm.nonTransportArea.noTransArea[i].children.length; jm++) {
          let len = vm.nonTransportArea.noTransArea[i].children[jm].childrenCountry.length;
          let lenCheck = vm.nonTransportArea.noTransArea[i].children[jm].checkModalCountry.length;
          if (len == lenCheck && lenCheck != 0) {
            // break;
          } else {
            noTranList = noTranList.concat(vm.nonTransportArea.noTransArea[i].children[jm].checkModalCountry);
          }
        }
      }
      vm.nonTransportArea.chooseNoTran = vm.unique(noTranList.concat(arrList));
    },

    //去重
    unique: function (arr) {
      var res = [];
      var json = {};
      for (var i = 0; i < arr.length; i++) {
        if (!json[arr[i]]) {
          res.push(arr[i]);
          json[arr[i]] = 1;
        }
      }
      return res;
    },

    //清空所选项
    clearCheckModal: function () {
      let vm = this;
      this.nonTransportArea.chooseNoTran = [];
      for (let i = 0; i < this.nonTransportArea.noTransArea.length; i++) {
        this.nonTransportArea.noTransArea[i].checkModal = [];
      }
      for (let kk = 0; kk < vm.nonTransportArea.noTransArea.length; kk++) {
        for (let q = 0; q < vm.nonTransportArea.noTransArea[kk].children.length; q++) {
          vm.nonTransportArea.noTransArea[kk].children[q].checkModalCountry = [];
        }
      }
    },

    //保存已选不送地区
    saveChooseModal: function () {
      let vm = this;
      vm.nonTransportArea.allListCountry = [];
      let noTransStr = 'Additional Locations,Worldwide,Domestic Location,Africa,Asia,Central America and Caribbean,Europe,North America,Oceania,South America';
      instance({
        method: 'post',
        url: 'v1/ebay/meta/excludeShippingLocation/getList',
        params: {
          siteId: vm.generalInfo.site,
          regions: noTransStr
        }
      }).then(function (data) {
        if (data.data.success) {
          let allList = data.data.data;
          for (let nm = 0; nm < vm.nonTransportArea.chooseNoTran.length; nm++) {
            for (let li = 0; li < allList.length; li++) {
              if (allList[li].description == vm.nonTransportArea.chooseNoTran[nm]) {
                vm.nonTransportArea.allListCountry.push(allList[li].location);
              }
            }
          }
        }
      })
      this.nonTransportArea.noTransChoose = this.nonTransportArea.chooseNoTran;
    },

    //获取支付信息
    getPayMentMethod: function () {
      let vm = this;
      if (!vm.generalInfo.site) {
        // this.errorClass = false;
        // this.errorShow = true;
        // this.errorTitle = "操作失败";
        // this.errorMsg = "请选择站点";
        // this.setTime();
        this.$message.error("请选择站点");
        return;
      }
      instance({
        method: 'post',
        url: 'v1/ebay/meta/paymentMethod/getCodeTypeList',
        params: {
          siteId: vm.generalInfo.site,
          categoryId: vm.productAtt.firstCator,
        }
      }).then(function (data) {
        if (data.data.success) {
          vm.payment.paymentMethod = data.data.data;
        }
      })
    },

    //获取paypal数据列表
    getAuthorShopList: function (_shopListItem) {
      console.log('_shopListItem',_shopListItem)
      console.log('this.shopList',this.shopList)
      this.payment.paypalSelect = '';
      if(!_shopListItem){
        this.payment.paypalList = [];
      }
      for (let i = 0; i < this.shopList.length; i++){
        if(this.shopList[i].id == _shopListItem){
          this.payment.paypalList = this.shopList[i].accounts
        }
      }
    },

    getAuthorShopListD(_shopListItemF){
      console.log('_shopListItem',_shopListItemF)
      console.log('this.shopList',this.shopList)
      if(!_shopListItemF){
        this.payment.paypalList = [];
      }
      for (let i = 0; i < this.shopList.length; i++){
        if(this.shopList[i].id == _shopListItemF){
          this.payment.paypalList = this.shopList[i].accounts
        }
      }
    },

    //改变paypal账号样式
    changeGetPaypalList: function () {
      this.payment.getPaypalList = true;
      this.payment.nopaypal = false;
    },

    //判断是否允许买家购买我的物品
    checkAlow: function () {
      if (parseInt(this.tradeRestrictions.hasAllow) == 0) {
        //获取买家限制
        // this.violateTimeFn();
        // this.violateNumFn();
        this.astrictNumFn();
        this.underCreditFn();
        // this.nonPaymentNumFn();
        // this.underBuyerFn();
        // this.underPeputationFn();
      }
    },

    //获取退货政策数据
    getPolicy: function () {
      let vm = this;
      instance({
        method: 'post',
        url: 'v1/ebay/meta/returnPolicy/getList',
        params: {
          siteId: vm.generalInfo.site,
          type: "returnsAcceptedOption"
        }
      }).then(function (data) {
        if (data.data.success) {
          vm.salesReturn.policy = data.data.data;
          vm.salesReturn.policySelect = vm.salesReturn.policy[0].code;
        }
      });
    },

    //选择退货政策
    choosePolicy: function () {
      this.salesReturn.policySelect == "ReturnsNotAccepted" ? this.salesReturn.show = false : this.salesReturn.show = true
    },

    //获取退货天数
    getDays: function () {
      let vm = this;
      instance({
        method: 'post',
        url: 'v1/ebay/meta/returnPolicy/getList',
        params: {
          siteId: vm.generalInfo.site,
          type: "returnsWithinOption"
        }
      }).then(function (data) {
        if (data.data.success) {
          vm.salesReturn.days = data.data.data;
          vm.salesReturn.daysSelsct = vm.salesReturn.days[0].code;
        }
      });
    },

    //获取退货方式
    getWay: function () {
      let vm = this;
      instance({
        method: 'post',
        url: 'v1/ebay/meta/returnPolicy/getList',
        params: {
          siteId: vm.generalInfo.site,
          type: "refundOption"
        }
      }).then(function (data) {
        if (data.data.success) {
          vm.salesReturn.way = data.data.data;
          vm.salesReturn.waySelect = vm.salesReturn.way[0].code;
        }
      });
    },

    //获取退货运费由谁负担
    getPrincipal: function () {
      let vm = this;
      instance({
        method: 'post',
        url: 'v1/ebay/meta/returnPolicy/getList',
        params: {
          siteId: vm.generalInfo.site,
          type: "shippingCostPaidByOption"
        }
      }).then(function (data) {
        if (data.data.success) {
          vm.salesReturn.principal = data.data.data;
          vm.salesReturn.principalSelect = vm.salesReturn.principal[0].code;
        }
      });
    },

    //获取折旧率
    getRateDepreciation: function () {
      let vm = this;
      instance({
        method: 'post',
        url: 'v1/ebay/meta/returnPolicy/getList',
        params: {
          siteId: vm.generalInfo.site,
          type: "restockingFeeValueOption"
        }
      }).then(function (data) {
        if (data.data.success) {
          vm.salesReturn.rateDepreciation = data.data.data;
          vm.salesReturn.rateDepSelect = vm.salesReturn.rateDepreciation[0].code;
        }
      });
    },


    //选择买家有没有palpal账号
    choosePaypalMomt: function () {
      if (!this.tradeRestrictions.hasPayPal) {
        this.tradeRestrictions.hasPayPalMomt = 1;
      } else {
        this.tradeRestrictions.hasPayPalMomt = 0;
      }
    },

    //
    chooseShipCountry: function () {
      if (!this.tradeRestrictions.shipToRegistrationCountry) {
        this.tradeRestrictions.shipToRegiCtrySelect = 1;
      } else {
        this.tradeRestrictions.shipToRegiCtrySelect = 0;
      }
    },

    //违反政策检举次数
    // violateNumFn: function () {
    //   let vm = this;
    //   instance({
    //     method: 'post',
    //     url: 'v1/ebay/meta/buyerRequirement/getList',
    //     params: {
    //       type: 'maximumBuyerPolicyViolations'
    //     }
    //   }).then(function (data) {
    //     if (data.data.success) {
    //       vm.tradeRestrictions.violateNum = data.data.data.data;
    //       vm.tradeRestrictions.violateNumSelect = vm.tradeRestrictions.violateNum[0].code;
    //     }
    //   })
    // },

    //违反政策检举时间范围
    // violateTimeFn: function () {
    //   let vm = this;
    //   instance({
    //     method: 'post',
    //     url: 'v1/ebay/meta/buyerRequirement/getList',
    //     params: {
    //       type: 'policyViolationDuration'
    //     }
    //   }).then(function (data) {
    //     if (data.data.success) {
    //       vm.tradeRestrictions.violateTime = data.data.data.data;
    //       vm.tradeRestrictions.violateTimeSelect = vm.tradeRestrictions.violateTime[0].code;
    //     }
    //   })
    // },

    //在过去10天内曾出价或购买我的物品，已达到我所设定的限制次数
    astrictNumFn: function () {
      let vm = this;
      instance({
        method: 'post',
        url: 'v1/ebay/meta/buyerRequirement/getList',
        params: {
          type: 'maximumItemCount'
        }
      }).then(function (data) {
        if (data.data.success) {
          vm.tradeRestrictions.astrictNum = data.data.data;
          vm.tradeRestrictions.astrictNumSelect = vm.tradeRestrictions.astrictNum[0].code;
        }
      })
    },

    //这项限制只适用于买家信用指数等于或低于这个值
    underCreditFn: function () {
      let vm = this;
      instance({
        method: 'post',
        url: 'v1/ebay/meta/buyerRequirement/getList',
        params: {
          type: 'requirementsMinimumFeedbackScore'
        }
      }).then(function (data) {
        if (data.data.success) {
          vm.tradeRestrictions.underCredit = data.data.data;
          vm.tradeRestrictions.underCreditSelect = vm.tradeRestrictions.underCredit[0].code;
        }
      })
    },

    //未付款次数
    // nonPaymentNumFn: function () {
    //   let vm = this;
    //   instance({
    //     method: 'post',
    //     url: 'v1/ebay/meta/buyerRequirement/getList',
    //     params: {
    //       type: 'maximumUnpaidItemStrikesCount'
    //     }
    //   }).then(function (data) {
    //     if (data.data.success) {
    //       vm.tradeRestrictions.nonPaymentNum = data.data.data.data;
    //       vm.tradeRestrictions.nonPaymentNumSelect = vm.tradeRestrictions.nonPaymentNum[0].code;
    //     }
    //   })
    // },

    //这项限制只适用于买家信用指数等于或低于这个值
    // underBuyerFn: function () {
    //   let vm = this;
    //   instance({
    //     method: 'post',
    //     url: 'v1/ebay/meta/buyerRequirement/getList',
    //     params: {
    //       type: 'maximumUnpaidItemStrikesDuration'
    //     }
    //   }).then(function (data) {
    //     if (data.data.success) {
    //       vm.tradeRestrictions.underBuyer = data.data.data.data;
    //       vm.tradeRestrictions.underBuyerSelect = vm.tradeRestrictions.underBuyer[0].code;
    //     }
    //   })
    // },

    //信用指标等于或低于这个值
    // underPeputationFn: function () {
    //   let vm = this;
    //   instance({
    //     method: 'post',
    //     url: 'v1/ebay/meta/buyerRequirement/getList',
    //     params: {
    //       type: 'minimumFeedbackScore'
    //     }
    //   }).then(function (data) {
    //     if (data.data.success) {
    //       vm.tradeRestrictions.underPeputation = data.data.data.data;
    //       vm.tradeRestrictions.underPeputationSelect = vm.tradeRestrictions.underPeputation[0].code;
    //     }
    //   })
    // },

    //刊登保存
    submitPublish: function (save) {
      this.dialogFormVisible = true;
      let publishParmas = {
        ebayGoodsAttributeList: [],//多属性
        shippingServiceOptionList: [],//运输
        ebayCategorySpecificsDraftValueList: [],//物品属性名称和值
        ossGoodsPicList: [],//商品OOS图片地址
      };
      let vm = this;
      // if(!vm.upToEbayFlag){
      //   vm.errorClass = false;
      //   vm.errorShow = true;
      //   vm.errorTitle = "保存失败";
      //   vm.errorMsg = "请上传商品图片到eBay";
      //   vm.setTime();
      //   vm.dialogFormVisible = false;
      //   return;
      // }
      if (!this.productAtt.firstCator) {
        // vm.errorClass = false;
        // vm.errorShow = true;
        // vm.errorTitle = "保存失败";
        // vm.errorMsg = "请选择第一商品分类";
        vm.$message.error("请选择第一商品分类");
        // vm.setTime();
        vm.dialogFormVisible = false;
        return;
      }

      if (this.productAtt.goodsState.length != 0) {
        if (!this.productAtt.goodsStateSelect) {
          // vm.errorClass = false;
          // vm.errorShow = true;
          // vm.errorTitle = "保存失败";
          // vm.errorMsg = "请选择物品状况";
          // vm.setTime();
          vm.$message.error("请选择物品状况");
          vm.dialogFormVisible = false;
          return;
        }
      }

      // "shippingService": this.intTransList[i].transTypeInSelect,
      //   "internationalService": 0,//国内国际运输
      //   "shippingServiceCost": this.intTransList[i].freight,//运费
      //   "shippingServiceAdditionalCost": this.intTransList[i].extra,// 额外费用
      //   "shippingServicePriority": i + 1,
      //   "shippingSurcharge": this.intTransList[i].extraCharge,//额外收费
      //   "freeShipping": this.intTransList[i].freeShipping == true ? 1 : 0//免运费
      //
      // "shippingService": this.inlandTransList[j].transTypeInSelect,
      //   "internationalService": 1,//国内国际运输
      //   "shippingServicePriority": j + 1,
      //   "shippingServiceCost": this.inlandTransList[j].freight,//运费
      //   "shippingServiceAdditionalCost": this.inlandTransList[j].extra,// 额外费用
      //   "shipToLocation": str,//运到
      //   "freeShipping": this.inlandTransList[j].freeShipping == true ? 1 : 0//免运费

      // for (let aa = 0; aa < this.intTransList.length; aa++){
      //   let currentAA = this.intTransList[aa];
      //   for (let bb = 0; this.intTransList.length; bb++){
      //     let currentBB = this.intTransList[bb];
      //     if (currentAA.transTypeInSelect.indexOf(currentBB.transTypeInSelect) != 0){
      //       if(currentAA.transTypeInSelect == currentBB.transTypeInSelect && currentAA.freight == currentBB.freight && currentAA.extra == currentBB.extra && currentAA.extraCharge == currentBB.extraCharge&& currentAA.freeShipping == currentBB.freeShipping){
      //         vm.$message.error('不能重复运输方式');
      //         vm.dialogFormVisible = false;
      //         return;
      //       }
      //     }
      //
      //   }
      // }
      var result = [];
          var obj = {};
          for(var i =0; i<this.intTransList.length; i++){
               if(!obj[this.intTransList[i].transTypeInSelect]){
                    result.push(this.intTransList[i]);
                 obj[this.intTransList[i].transTypeInSelect] = true;
                 }else {
                 vm.$message.error('不能重复运输方式');
                 vm.dialogFormVisible = false;
                 return;
               }
            }

      var result1 = [];
      var obj1 = {};
      for(var i =0; i<this.inlandTransList.length; i++){
        if(!obj1[this.inlandTransList[i].transTypeInSelect]){
          result1.push(this.inlandTransList[i]);
          obj1[this.inlandTransList[i].transTypeInSelect] = true;
        }else {
          vm.$message.error('不能重复运输方式');
          vm.dialogFormVisible = false;
          return;
        }
      }


      //
      // for (let cc = 0; cc < this.inlandTransList.length; cc++){
      //   let currentAAA = this.inlandTransList[cc];
      //   let str = '';
      //   for (let nn = 0; nn < this.inlandTransList[cc].checkItems.length; nn++) {
      //     str += this.inlandTransList[cc].checkItems[nn].value + ",";
      //   }
      //
      //   for (let dd = 0; this.inlandTransList.length; dd++){
      //     let str1 = '';
      //     for (let mm = 0; mm < this.inlandTransList[dd].checkItems.length; mm++) {
      //       str1 += this.inlandTransList[dd].checkItems[mm].value + ",";
      //     }
      //     let currentBBB = this.inlandTransList[dd];
      //     if(currentAAA.transTypeInSelect == currentBBB.transTypeInSelect && currentAAA.freight == currentBBB.freight && currentAAA.extra == currentBBB.extra && str == str1){
      //       vm.$message.error('不能重复运输方式');
      //       vm.dialogFormVisible = false;
      //       return;
      //     }
      //   }
      // }

      for (let pro = 0; pro < vm.productAtt.properties.length; pro++) {
        let current = vm.productAtt.properties[pro];
        if (current.maxValues == 1 && current.minValues == 1) {
          if (!current.selectModal) {
            // vm.errorClass = false;
            // vm.errorShow = true;
            // vm.errorTitle = "保存失败";
            // vm.errorMsg = "请选择【"+current.name+"】物品属性";
            // vm.setTime();
            vm.$message.error("请选择【" + current.name + "】物品属性");
            vm.dialogFormVisible = false;
            return;
          }
        }
      }
      // if(!this.productAtt.firstStor){
      //   vm.errorClass = false;
      //   vm.errorShow = true;
      //   vm.errorTitle = "保存失败";
      //   vm.errorMsg = "请选择第一店铺分类";
      //   vm.setTime();
      //   return;
      // }
      if (this.generalInfo.sellWay == 'FixedPriceItem') {
        if (!this.titleAndPrice.fixedPrice) {
          // vm.errorClass = false;
          // vm.errorShow = true;
          // vm.errorTitle = "保存失败";
          // vm.errorMsg = "请输入一口价";
          // vm.setTime();
          vm.$message.error("请输入一口价");
          vm.dialogFormVisible = false;
          return;
        }
      }
      if (this.generalInfo.sellWay == 'Chinese') {
        if (!this.titleAndPrice.startPrice) {
          // vm.errorClass = false;
          // vm.errorShow = true;
          // vm.errorTitle = "保存失败";
          // vm.errorMsg = "请输入一口价";
          // vm.setTime();
          vm.$message.error("请输入一口价");
          vm.dialogFormVisible = false;
          return;
        }
      }

      if (this.dimension.results.length != 0) {
        for (let di = 0; di < this.dimension.results.length; di++) {
          if (!this.dimension.results[di].SKU) {
            // vm.errorClass = false;
            // vm.errorShow = true;
            // vm.errorTitle = "保存失败";
            // vm.errorMsg = "请输入多属性中的SKU";
            // vm.setTime();
            vm.$message.error("请输入多属性中的平台sku");
            vm.dialogFormVisible = false;
            return;
          }
          if (!this.dimension.results[di].ebaySku) {
            // vm.errorClass = false;
            // vm.errorShow = true;
            // vm.errorTitle = "保存失败";
            // vm.errorMsg = "请输入多属性中的SKU";
            // vm.setTime();
            vm.$message.error("请选择多属性中的系统SKU");
            vm.dialogFormVisible = false;
            return;
          }
          if (!this.dimension.results[di].num) {
            // vm.errorClass = false;
            // vm.errorShow = true;
            // vm.errorTitle = "保存失败";
            // vm.errorMsg = "请输入多属性中的数量";
            // vm.setTime();
            vm.$message.error("请输入多属性中的数量");
            vm.dialogFormVisible = false;
            return;
          }
          if (!this.dimension.results[di].price) {
            // vm.errorClass = false;
            // vm.errorShow = true;
            // vm.errorTitle = "保存失败";
            // vm.errorMsg = "请输入多属性中的价格";
            // vm.setTime();
            vm.$message.error("请输入多属性中的价格");
            vm.dialogFormVisible = false;
            return;
          }
        }
      }

      if (!this.locationGood.countrySelect) {
        // vm.errorClass = false;
        // vm.errorShow = true;
        // vm.errorTitle = "保存失败";
        // vm.errorMsg = "请选择国家";
        // vm.setTime();
        vm.$message.error("请选择国家");
        vm.dialogFormVisible = false;
        return;
      }

      if (this.intTransList.length == 0) {
        // vm.errorClass = false;
        // vm.errorShow = true;
        // vm.errorTitle = "保存失败";
        // vm.errorMsg = "请添加第一国内运输";
        // vm.setTime();
        vm.$message.error("请添加第一国内运输");
        vm.dialogFormVisible = false;
        return;
      }
      if (!this.intTransList[0].transTypeInSelect) {
        // vm.errorClass = false;
        // vm.errorShow = true;
        // vm.errorTitle = "保存失败";
        // vm.errorMsg = "请选择第一国内运输的运输方式";
        // vm.setTime();
        vm.$message.error("请选择第一国内运输的运输方式");
        vm.dialogFormVisible = false;
        return;
      }
      for (let tranWay = 0; tranWay < this.intTransList.length; tranWay++){
        let currentTran = this.intTransList[tranWay];
        let tranWayIndex = {
          0:'一',
          1:'二',
          2:'三',
          3:'四',
          4:'五',
        }
        if (currentTran.freight > 100){
          vm.$message.error('第'+tranWayIndex[tranWay]+'国内运输的运费不能大于100');
          vm.dialogFormVisible = false;
          return;
        }
        if (currentTran.extra > 100){
          vm.$message.error('第'+tranWayIndex[tranWay]+'国内运输的额外没件加收不能大于100');
          vm.dialogFormVisible = false;
          return;
        }
        if (currentTran.extraCharge > 100){
          vm.$message.error('第'+tranWayIndex[tranWay]+'国内运输的AK,HI,PR 额外收费不能大于100');
          vm.dialogFormVisible = false;
          return;
        }
      }
      for (let tranWay = 0; tranWay < this.inlandTransList.length; tranWay++){
        let currentTran = this.inlandTransList[tranWay];
        let tranWayIndex = {
          0:'一',
          1:'二',
          2:'三',
          3:'四',
          4:'五',
        }
        if (currentTran.freight > 100){
          vm.$message.error('第'+tranWayIndex[tranWay]+'国际运输的运费不能大于100');
          vm.dialogFormVisible = false;
          return;
        }
        if (currentTran.extra > 100){
          vm.$message.error('第'+tranWayIndex[tranWay]+'国际运输的额外没件加收不能大于100');
          vm.dialogFormVisible = false;
          return;
        }
      }
      // if(!this.intTransList[0].freight && !this.intTransList[0].freeShipping && this.intTransList[0].freight != 0){
      //   vm.errorClass = false;
      //   vm.errorShow = true;
      //   vm.errorTitle = "保存失败";
      //   vm.errorMsg = "请输入第一国内运输的运费";
      //   vm.setTime();
      //   vm.dialogFormVisible = false;
      //   return;
      // }
      // if(!this.intTransList[0].extra){
      //   vm.errorClass = false;
      //   vm.errorShow = true;
      //   vm.errorTitle = "保存失败";
      //   vm.errorMsg = "请输入第一国内运输的额外没件加收";
      //   vm.setTime();
      //   vm.dialogFormVisible = false;
      //   return;
      // }
      // if(!this.intTransList[0].extraCharge){
      //   vm.errorClass = false;
      //   vm.errorShow = true;
      //   vm.errorTitle = "保存失败";
      //   vm.errorMsg = "请输入第一国内运输的AK,HI,PR 额外收费";
      //   vm.setTime();
      //   vm.dialogFormVisible = false;
      //   return;
      // }

      let sku = '';
      if (vm.addProductList.length == 0) {
        sku = '';
      } else {
        sku = vm.addProductList[0].sku;
      }
      for (let up = 0; up < this.typeList.length; up++) {
        if (this.typeList[up].code.toLowerCase() == 'upc') {
          vm.generalInfo.upc = this.typeList[up].model;
        }
        if (this.typeList[up].code.toLowerCase() == 'isbn') {
          vm.generalInfo.isbn = this.typeList[up].model;
        }
        if (this.typeList[up].code.toLowerCase() == 'ean') {
          vm.generalInfo.ean = this.typeList[up].model;
        }
      }

      // alert(this.dimension.results.length);
      // if (this.dimension.results.length == 0){
      //   this.$message.error("请选择系统SKU！");
      // }
      publishParmas.ebayGoodsDraft = {
        "shopId": vm.generalInfo.shop,
        "siteId": vm.generalInfo.site,
        "id": vm.publishId,
        "listingType": vm.generalInfo.sellWay,//刊登类型
        "sku": sku,
        "ebaySku": vm.quoteSKU,
        "upc": vm.generalInfo.upc,
        "isbn": vm.generalInfo.isbn,
        "ean": vm.generalInfo.ean,
        "category1": vm.productAtt.firstCator,//第一分类ID
        "category2": vm.productAtt.secondCatorL,//第二分类ID
        "storeCategory1": vm.productAtt.firstStor,//第一店铺分类
        "storeCategory2": vm.productAtt.secondStor,//第二店铺分类
        "conditionId": vm.productAtt.goodsStateSelect,//物品状况ID
        "title": vm.titleAndPrice.publishTitle,
        "subtitle": vm.titleAndPrice.publishsubhead,
        "unit": vm.titleAndPrice.units,//金额单位
        "duration": vm.titleAndPrice.dateIssuedSelect,//上架时间
        "quantity": vm.titleAndPrice.quantity,
        "stockWarning": vm.titleAndPrice.inventoryWarning,//库存预警
        "startPrice": vm.titleAndPrice.fixedPrice,//起始价格,在竞拍时,传递该参数
        "reservePrice": vm.titleAndPrice.fixedPrice,//保底价,在竞拍时,传递该参数
        "vat": vm.titleAndPrice.vatTaxRate,//税率
        "fixedPrice": vm.titleAndPrice.fixedPrice,//一口价（（在竞拍中，它代表BuyItNowPrice））
        "goodsDesc": vm.describeInfo.goodsDescribe,
        "pictureCorrelation": vm.checkModel,//图片关联多属性名称
        "countryCode": vm.locationGood.countrySelect,//国家代码
        "postalCode": vm.locationGood.postcode,//邮政编码
        "dispatchTimeMax": vm.processingTime,//处理时间(工作日)
        "shippingDomesticType": vm.logisticsSet.dttSelect,//国内运输类型
        "shippingInternationalType": vm.logisticsSet.transportTypeSelect,//国际运输类型
        "originatingPostalCode": vm.logisticsSet.postcode,//始发地邮政编码
        "packagingHandlingCosts": vm.logisticsSet.domesticServiceCharge,//国内手续费
        "internationalPackagingHandlingCosts": vm.logisticsSet.interCommission,//国际手续费
        "measurementUnit": vm.logisticsSet.measurementUnit,//测量单位
        "packageDepth": vm.logisticsSet.dimensionsLong,//尺寸规格-深度
        "packageLength": vm.logisticsSet.dimensionsWide,//尺寸规格-长度
        "packageWidth": vm.logisticsSet.dimensionsHigh,//尺寸规格-宽度
        "shippingIrregular": vm.logisticsSet.irregularShape ? 1 : 0,//是否是不规则形状（1：是  0：否）
        "weightMajor": vm.logisticsSet.measurelbs,//估量重量lbs
        "weightMinor": vm.logisticsSet.measureoz,//估量重量oz
        "shippingPackage": vm.logisticsSet.size,//运输包装Code
        "whId": vm.locationGood.wareHouseSelect,//仓库Id
        "whName": vm.locationGood.whName,//仓库名称
        "excludeLocation": vm.nonTransportArea.allListCountry.join(','),//不送往位置（多个location用逗号隔开）
        // "excludeLocation":vm.nonTransportArea.allListCountry.join(','),//不送往位置（多个location用逗号隔开）
        "paymentMethod": vm.payment.paypalcheckItems.join(','),//支付方式（多个用逗号隔开）
        "paypal": vm.payment.paypalSelect,//paypal账号test@test.com
        "paymentDesc": vm.payment.paymentExplain,//支付描述
        "returnsAcceptedOption": vm.salesReturn.policySelect,//退货政策
        "returnsWithinOption": vm.salesReturn.daysSelsct,//退货天数
        "refundOption": vm.salesReturn.waySelect,//退货方式
        "shippingCostPaidByOption": vm.salesReturn.principalSelect,//退货运费由谁负担
        "restockingFeeValueOption": vm.salesReturn.rateDepSelect,//折旧费
        "returnPolicyDesc": vm.salesReturn.details,//退货政策详情
        "isAllowBuy": vm.tradeRestrictions.hasAllow,//1:允许所有买家购买我的物品 0:不允许以下买家购买我的物品
        // "linkedPaypalAccount": vm.tradeRestrictions.hasPayPalMomt,//1:勾选“没有PayPal账户”   0:没有勾选“没有PayPal账户”
        "shipToRegistrationCountry": vm.tradeRestrictions.shipToRegiCtrySelect,//1:勾选“主要运送地址在我的运送范围之外” 0：没有勾选“主要运送地址在我的运送范围之外”
        // "maximumBuyerPolicyViolations": vm.tradeRestrictions.violateNumSelect,//违反政策检举次数
        // "policyViolationDuration": vm.tradeRestrictions.violateTimeSelect,//违反政策检举时间范围
        "maximumItemCount": vm.tradeRestrictions.astrictNumSelect,//在过去10天内曾出价或购买我的物品，已达到我所设定的限制次数
        "requirementsMinimumFeedbackScore": vm.tradeRestrictions.underCreditSelect,//这项限制只适用于买家信用指数等于或低于这个值
        // "maximumUnpaidItemStrikesCount": vm.tradeRestrictions.nonPaymentNumSelect,//未付款次数
        // "maximumUnpaidItemStrikesDuration": vm.tradeRestrictions.underBuyerSelect,//在过去多少时间未付款
        "minimumFeedbackScore": -1//信用指标等于或低于这个值
      };

      // publishParmas.ebayCategorySpecificsDraftValueList[];
      for (let i = 0; i < this.productAtt.properties.length; i++) {
        let _obj = {};
        _obj.name = this.productAtt.properties[i].name;
        if (this.productAtt.properties[i].minValues == null && this.productAtt.properties[i].maxValues > 1) {
          _obj.value = this.productAtt.properties[i].selectChecked.join(',');
        } else {
          _obj.value = this.productAtt.properties[i].selectModal;
        }
        publishParmas.ebayCategorySpecificsDraftValueList.push(_obj);
      }

      for (let art = 0; art < vm.itemProperties.length; art++) {
        let _artObk = {};
        _artObk.name = vm.itemProperties[art].name;
        _artObk.value = vm.itemProperties[art].value;
        publishParmas.ebayCategorySpecificsDraftValueList.push(_artObk);
      }

      for (let j = 0; j < this.dimension.results.length; j++) {
        let attrObj = {};
        for (let i = 0; i < this.mulSetUp.length; i++) {
          attrObj["attributeName" + (i + 1)] = this.mulSetUp[i].attr;
        }
        let arr = this.dimension.results[j].SKU.split('-');
        for (let n = 0; n < arr.length - (arr.length - this.mulSetUp.length); n++) {
          if (n >= arr.length) {
            return;
          } else {
            attrObj["attributeValue" + (n + 1)] = arr[arr.length - this.mulSetUp.length + n];
            delete attrObj["attributeValue" + (arr.length)];
          }
        }
        attrObj.ebaySku = this.dimension.results[j].SKU;
        attrObj.sku = this.dimension.results[j].ebaySku;
        attrObj.quantity = this.dimension.results[j].num;
        attrObj.retailPrice = this.dimension.results[j].price;
        attrObj.productId = this.dimension.results[j].UPC;
        attrObj.productIdType = this.multiattributeSetting.UPCselect;
        attrObj.ossGoodsPicUrl = this.dimension.results[j].pic + '';
        publishParmas.ebayGoodsAttributeList.push(attrObj);
      }

      let intTransArr = [];
      for (let i = 0; i < this.intTransList.length; i++) {
        let intTransObj = {};
        intTransObj = {
          "shippingService": this.intTransList[i].transTypeInSelect,
          "internationalService": 0,//国内国际运输
          "shippingServiceCost": this.intTransList[i].freight,//运费
          "shippingServiceAdditionalCost": this.intTransList[i].extra,// 额外费用
          "shippingServicePriority": i + 1,
          "shippingSurcharge": this.intTransList[i].extraCharge,//额外收费
          "freeShipping": this.intTransList[i].freeShipping == true ? 1 : 0//免运费
        }
        intTransArr.push(intTransObj);
      }
      let inlandTransArr = [];
      for (let j = 0; j < this.inlandTransList.length; j++) {
        let str = '';
        for (let n = 0; n < this.inlandTransList[j].checkItems.length; n++) {
          str += this.inlandTransList[j].checkItems[n].value + ",";
        }
        let inlandTransObj = {};
        inlandTransObj = {
          "shippingService": this.inlandTransList[j].transTypeInSelect,
          "internationalService": 1,//国内国际运输
          "shippingServicePriority": j + 1,
          "shippingServiceCost": this.inlandTransList[j].freight,//运费
          "shippingServiceAdditionalCost": this.inlandTransList[j].extra,// 额外费用
          "shipToLocation": str,//运到
          "freeShipping": this.inlandTransList[j].freeShipping == true ? 1 : 0//免运费
        }
        inlandTransArr.push(inlandTransObj)
      }
      publishParmas.shippingServiceOptionList = inlandTransArr.concat(intTransArr);
      for (let jk = 0; jk < vm.multipleList.length; jk++) {
        publishParmas.ossGoodsPicList.push(vm.multipleList[jk].src);
      }

      let url = '';
      if (save == 'save') {
        url = 'v1/ebay/draft/edit/save';
      }
      if (save == 'publish') {
        url = 'v1/ebay/draft/edit/saveAndAddItem';
      }
      // console.log(JSON.stringify(publishParmas))

      console.log(publishParmas)
      instance({
        method: 'post',
        url: url,
        data: publishParmas
      }).then(function (data) {
        console.log(data)
        if (data.data.success) {
          vm.dialogFormVisible = false;
          vm.$router.push({path: '/v1/ebay/goods/getList'})
        } else {
          vm.dialogFormVisible = false;
          vm.$message.error(data.data.msg);
          vm.setTime();
        }
      });
    },

    //编辑获取草稿数据
    getDraftEdit: function () {

      let _draftId = this.getParams();
      let vm = this;
      vm.dialogFormVisible = true;
      instance({
        method: 'post',
        url: 'v1/ebay/draft/edit/getData',
        params: {
          draftId: _draftId
        }
      }).then(function (data) {
        if (data.data.success) {
          vm.dialogFormVisible = false;
          console.log('data.data.data',data.data.data)
          let publishParmas = data.data.data;
          let ebayGoodsDraft = data.data.data.ebayGoodsDraft;
          let ebayCategorySpecificsDraftValueList = data.data.data.ebayCategorySpecificsDraftValueList;//物品属性名称和值
          vm.attrSave = ebayCategorySpecificsDraftValueList;
          let ebayGoodsAttributeList = data.data.data.ebayGoodsAttributeList;//多属性
          let ossGoodsPicList = data.data.data.ossGoodsPicList;//商品OOS图片地址
          vm.shippingServiceOptionList = data.data.data.shippingServiceOptionList;//货运相关
          vm.generalInfo.shop = ebayGoodsDraft.shopId;
          vm.generalInfo.site = ebayGoodsDraft.siteId + '';
          vm.generalInfo.sellWay = ebayGoodsDraft.listingType;//刊登类型
          vm.publishId = ebayGoodsDraft.id,
          vm.quoteSKU = ebayGoodsDraft.ebaySku;
          vm.generalInfo.upc = ebayGoodsDraft.upc,
          vm.generalInfo.isbn = ebayGoodsDraft.isbn,
          vm.generalInfo.ean = ebayGoodsDraft.ean,
          vm.productAtt.firstCator = ebayGoodsDraft.category1;//第一分类ID
          vm.firstCator = ebayGoodsDraft.category1;
          vm.productAtt.secondCatorL = ebayGoodsDraft.category2;//第二分类ID
          vm.productAtt.firstStor = ebayGoodsDraft.storeCategory1;//第一店铺分类
          vm.productAtt.secondStor = ebayGoodsDraft.storeCategory2;//第二店铺分类
          vm.productAtt.goodsStateSelect = ebayGoodsDraft.conditionId;//物品状况ID
          vm.titleAndPrice.publishTitle = ebayGoodsDraft.title;
          vm.titleAndPrice.publishsubhead = ebayGoodsDraft.subtitle;
          vm.titleAndPrice.units = ebayGoodsDraft.unit;//金额单位
          vm.titleAndPrice.dateIssuedSelect = ebayGoodsDraft.duration;//上架时间
          vm.titleAndPrice.quantity = ebayGoodsDraft.quantity;
          vm.titleAndPrice.inventoryWarning = ebayGoodsDraft.stockWarning;//库存预警
          vm.titleAndPrice.startPrice = ebayGoodsDraft.startPrice;//起始价格,在竞拍时,传递该参数
          vm.titleAndPrice.reservePrice = ebayGoodsDraft.reservePrice;//保底价,在竞拍时,传递该参数
          vm.titleAndPrice.vatTaxRate = ebayGoodsDraft.vat;//税率
          vm.titleAndPrice.fixedPrice = ebayGoodsDraft.fixedPrice;//一口价（（在竞拍中，它代表BuyItNowPrice））
          vm.describeInfo.goodsDescribe = ebayGoodsDraft.goodsDesc;
          vm.checkModel = ebayGoodsDraft.pictureCorrelation;//图片关联多属性名称
          vm.locationGood.countrySelect = ebayGoodsDraft.countryCode;//国家代码
          vm.locationGood.postcode = ebayGoodsDraft.postalCode;//邮政编码
          vm.processingTime = ebayGoodsDraft.dispatchTimeMax;//处理时间(工作日)
          vm.logisticsSet.dttSelect = ebayGoodsDraft.shippingDomesticType;//国内运输类型
          vm.logisticsSet.transportTypeSelect = ebayGoodsDraft.shippingInternationalType;//国际运输类型
          vm.logisticsSet.postcode = ebayGoodsDraft.originatingPostalCode;//始发地邮政编码
          vm.logisticsSet.domesticServiceCharge = ebayGoodsDraft.packagingHandlingCosts;//国内手续费
          vm.logisticsSet.interCommission = ebayGoodsDraft.internationalPackagingHandlingCosts;//国际手续费
          vm.logisticsSet.measurementUnit = ebayGoodsDraft.measurementUnit;//测量单位
          vm.logisticsSet.dimensionsLong = ebayGoodsDraft.packageDepth;//尺寸规格-深度
          vm.logisticsSet.dimensionsWide = ebayGoodsDraft.packageLength;//尺寸规格-长度
          vm.logisticsSet.dimensionsHigh = ebayGoodsDraft.packageWidth;//尺寸规格-宽度
          vm.logisticsSet.irregularShape = ebayGoodsDraft.shippingIrregular == 1 ? true : false;//是否是不规则形状（1：是  0：否）
          vm.logisticsSet.measurelbs = ebayGoodsDraft.weightMajor;//估量重量lbs
          vm.logisticsSet.measureoz = ebayGoodsDraft.weightMinor;//估量重量oz
          vm.logisticsSet.size = ebayGoodsDraft.shippingPackage;//运输包装Code
          vm.locationGood.wareHouseSelect = ebayGoodsDraft.whId;//仓库Id
          vm.locationGood.whName = ebayGoodsDraft.whName;//仓库名称
          // "excludeLocation":vm.nonTransportArea.noTransChoose.join(','),//不送往位置（多个location用逗号隔开）
          // // "excludeLocation":vm.nonTransportArea.allListCountry.join(','),//不送往位置（多个location用逗号隔开）
          vm.payment.paypalcheckItems = ebayGoodsDraft.paymentMethod.split(',');//支付方式（多个用逗号隔开）
          vm.payment.paypalSelect = ebayGoodsDraft.paypal;//paypal账号
          vm.paypalSelect = ebayGoodsDraft.paypal;
          vm.payment.paymentExplain = ebayGoodsDraft.paymentDesc;//支付描述
          vm.salesReturn.policySelect = ebayGoodsDraft.returnsAcceptedOption;//退货政策
          vm.salesReturn.daysSelsct = ebayGoodsDraft.returnsWithinOption;//退货天数
          vm.salesReturn.waySelect = ebayGoodsDraft.refundOption;//退货方式
          vm.salesReturn.principalSelect = ebayGoodsDraft.shippingCostPaidByOption;//退货运费由谁负担
          vm.salesReturn.rateDepSelect = ebayGoodsDraft.restockingFeeValueOption;//折旧费
          vm.salesReturn.details = ebayGoodsDraft.returnPolicyDesc;//退货政策详情
          vm.tradeRestrictions.hasAllow = ebayGoodsDraft.isAllowBuy;//1:允许所有买家购买我的物品 0:不允许以下买家购买我的物品
          // vm.tradeRestrictions.hasPayPal = ebayGoodsDraft.linkedPaypalAccount == 1 ? true : false,//1:勾选“没有PayPal账户”   0:没有勾选“没有PayPal账户”
          vm.tradeRestrictions.shipToRegistrationCountry = ebayGoodsDraft.shipToRegistrationCountry == 1 ? true : false;//1:勾选“主要运送地址在我的运送范围之外” 0：没有勾选“主要运送地址在我的运送范围之外”
          // vm.tradeRestrictions.violateNumSelect = ebayGoodsDraft.maximumBuyerPolicyViolations,//违反政策检举次数
          vm.tradeRestrictions.violateTimeSelect = ebayGoodsDraft.policyViolationDuration;//违反政策检举时间范围
          vm.tradeRestrictions.astrictNumSelect = ebayGoodsDraft.maximumItemCount;//在过去10天内曾出价或购买我的物品，已达到我所设定的限制次数
          vm.tradeRestrictions.underCreditSelect = ebayGoodsDraft.requirementsMinimumFeedbackScore;//这项限制只适用于买家信用指数等于或低于这个值
          // vm.tradeRestrictions.nonPaymentNumSelect = ebayGoodsDraft.maximumUnpaidItemStrikesCount,//未付款次数
          // vm.tradeRestrictions.underBuyerSelect = ebayGoodsDraft.maximumUnpaidItemStrikesDuration,//在过去多少时间未付款
          vm.tradeRestrictions.underPeputationSelect = ebayGoodsDraft.minimumFeedbackScore;//信用指标等于或低于这个值

          //不送地区
          if (ebayGoodsDraft.excludeLocation) {
            let noTran = ebayGoodsDraft.excludeLocation.split(',');
            if (noTran) {
              vm.nonTransportArea.noTransBoolean = true;
            }
            let noTransStr = 'Additional Locations,Worldwide,Domestic Location,Africa,Asia,Central America and Caribbean,Europe,North America,Oceania,South America';
            instance({
              method: 'post',
              url: 'v1/ebay/meta/excludeShippingLocation/getList',
              params: {
                siteId: vm.generalInfo.site,
                regions: noTransStr
              }
            }).then(function (data) {
              if (data.data.success) {
                let allList = data.data.data;
                for (let nm = 0; nm < noTran.length; nm++) {
                  for (let li = 0; li < allList.length; li++) {
                    if (allList[li].location == noTran[nm]) {
                      vm.nonTransportArea.noTransChoose.push(allList[li].description);
                    }
                  }
                }
              }
            });
          }


          if (ossGoodsPicList) {
            for (let pic = 0; pic < ossGoodsPicList.length; pic++) {
              let file = {};
              file.src = ossGoodsPicList[pic];
              file.hasClass = true;
              file.noClass = false;
              vm.multipleList.push(file);
            }
            vm.multipDefault.length = 12 - ossGoodsPicList.length
          }

          if (vm.productAtt.firstCator && _draftId && vm.attrSave) {
            vm.getPath(1)
          }
          if (vm.productAtt.secondCatorL && _draftId  && vm.attrSave) {
            vm.getPath(0)
          }
          if (ebayGoodsAttributeList.length != 0) {
            for (let uu = 0; uu < ebayGoodsAttributeList.length; uu++) {
              vm.multiattributeSetting.UPCselect = ebayGoodsAttributeList[uu].productIdType;
              let _objAttr = {
                pic: []
              };
              _objAttr.SKU = ebayGoodsAttributeList[uu].ebaySku;
              _objAttr.ebaySku = ebayGoodsAttributeList[uu].sku;
              _objAttr.num = ebayGoodsAttributeList[uu].quantity;
              _objAttr.price = ebayGoodsAttributeList[uu].retailPrice;
              _objAttr.UPC = ebayGoodsAttributeList[uu].productId;
              _objAttr.pic.push(ebayGoodsAttributeList[uu].ossGoodsPicUrl);
              vm.dimension.results.push(_objAttr);
            }
            if (ebayGoodsAttributeList[0].attributeName1) {
              let obj = {};
              obj.attr = ebayGoodsAttributeList[0].attributeName1;
              obj.attrArr = [];
              vm.mulSetUp.push(obj)
            }
            if (ebayGoodsAttributeList[0].attributeName2) {
              let obj = {};
              obj.attr = ebayGoodsAttributeList[0].attributeName2;
              obj.attrArr = [];
              vm.mulSetUp.push(obj)
            }
            if (ebayGoodsAttributeList[0].attributeName3) {
              let obj = {};
              obj.attr = ebayGoodsAttributeList[0].attributeName3;
              obj.attrArr = [];
              vm.mulSetUp.push(obj)
            }


            for (let ll = 0; ll < vm.mulSetUp.length; ll++) {
              for (let hh = 0; hh < ebayGoodsAttributeList.length; hh++) {
                if (vm.mulSetUp[ll].attr == ebayGoodsAttributeList[hh].attributeName1) {
                  let _obj = {};
                  _obj.attr = ebayGoodsAttributeList[hh].attributeValue1;
                  vm.mulSetUp[ll].attrArr.push(_obj);
                }
              }
            }
            for (let ll = 0; ll < vm.mulSetUp.length; ll++) {
              for (let hh = 0; hh < ebayGoodsAttributeList.length; hh++) {
                if (vm.mulSetUp[ll].attr == ebayGoodsAttributeList[hh].attributeName2) {
                  let _obj = {};
                  _obj.attr = ebayGoodsAttributeList[hh].attributeValue2;
                  vm.mulSetUp[ll].attrArr.push(_obj)
                }
              }
            }
            for (let ll = 0; ll < vm.mulSetUp.length; ll++) {
              for (let hh = 0; hh < ebayGoodsAttributeList.length; hh++) {
                if (vm.mulSetUp[ll].attr == ebayGoodsAttributeList[hh].attributeName3) {
                  let _obj = {};
                  _obj.attr = ebayGoodsAttributeList[hh].attributeValue3;
                  vm.mulSetUp[ll].attrArr.push(_obj);
                }
              }
            }

            for (let mu = 0; mu < vm.mulSetUp.length; mu++) {
              for (let lk = 0; lk < vm.mulSetUp[mu].attrArr.length; lk++) {
                for (let kl = 0; kl < vm.mulSetUp[mu].attrArr.length; kl++) {
                  if (lk != kl) {
                    if (vm.mulSetUp[mu].attrArr[lk]['attr'] == vm.mulSetUp[mu].attrArr[kl]['attr']) {
                      vm.mulSetUp[mu].attrArr.splice(kl, 1)
                    }
                  }
                }
              }
            }
            // vm.mulSetUp[0].attrArr = vm.distinct(vm.mulSetUp[0].attrArr);

            // console.log(vm.mulSetUp)


          }
          //获取退货天数
          vm.getDays();

          //获取包裹大小
          vm.getPackageSize();

          //获取退货方式
          vm.getWay();
          //查找SKU产品
          if (ebayGoodsDraft.sku){
            vm.findSKUProduct(ebayGoodsDraft.sku);
          }
          vm.getAuthorShopListD(vm.generalInfo.shop)
        }
      })

    },

    //根据sku查找商品
    findSKUProduct: function (_sku) {
      // debugger;
      let vm = this;
      instance({
        method: 'post',
        url: '/v1/goods/getList',
        params: {
          // name: _sku
          sku: _sku
        }
      }).then(function (data) {
        console.log(data)
        if (data.data.success) {
          console.log(data)
          vm.addProductList = data.data.data.list;
          // vm.addProductList[0].goodsCn = data.data.data[0].goodsName;
        }
      })
    },


    getStrleng: function (str) {
      for (let i = 0; i < str.length; i++) {
        if (str.charCodeAt(i) > 0 && str.charCodeAt(i) < 128) {
          this.myLen++
        } else {
          this.myLen += 2;
        }
      }
    },

    addPic(e) {
      let vm = this;
      if (!this.quoteSKU){
        this.$message.error("请先输入平台SKU！");
      }
      if (!vm.generalInfo.site){
        vm.$message.error("请选择站点");
        return false
      }
      if (!vm.generalInfo.shop){
        vm.$message.error("请选择店铺");
        return false
      }
      e.preventDefault();
      $(e.currentTarget).parent().find('.table-file').trigger('click');
      return false;
    },
    onFileChange(index, e) {
      let vm = this;
      let files = e.target.files || e.dataTransfer.files;
      for (var i = 0; i < files.length; i++) {
        var reader = new FileReader();
        reader.readAsDataURL(files[i]);
        reader.onload = function (e) {
          // file.src = e.target.result
        };
        vm.doUpLoadFilePic(files[i], index)
      }
      if (!files.length) return;
    },

    doUpLoadFilePic: function (file, index) {
      let vm = this;
      let form = new FormData();
      form.append('file', file, file.name);
      form.append("key", vm.dimension.results[index].SKU);
      form.append("type", "ebayItems");
      form.append("siteId", vm.generalInfo.site);
      form.append("shopId", vm.generalInfo.shop);
      console.log("form",form)
      axios({
        method: 'post',
        url: baseURL + '/v1/goods/uploadPic',
        headers: {
          'Content-Type': 'multipart/form-data'
        },
        data: form,
      }).then(function (data) {
        if (data.data.code == '9999') {
          vm.$router.push({
            path: '/login',
          });
          return
        }
        if ( data.data.code == '0000') {
          vm.$router.push({
            path: '/401',
          });
          return
        }
        if ( data.data.code == '1111') {
          vm.$router.push({
            path: '/401',
          });
          return
        }
        if (data.data.success) {
          vm.dimension.results[index].pic = data.data.data;
          let formObj = new FormData();
          formObj.append('files', file, file.name);
          formObj.append("ebaySku", vm.dimension.results[index].SKU);
          formObj.append("ossGoodsPicUrls", vm.dimension.results[index].pic);
          formObj.append("siteId", vm.generalInfo.site);
          formObj.append("shopId", vm.generalInfo.shop);
          axios({
            method: 'post',
            url: baseURL + '/v1/ebay/uploadPicturesToEPS',
            headers: {
              'Content-Type': 'multipart/form-data'
            },
            data: formObj
          }).then(function (data) {
            if (data.data.code == '9999') {
              vm.$router.push({
                path: '/login',
              });
              return
            }
            if ( data.data.code == '0000') {
              vm.$router.push({
                path: '/401',
              });
              return
            }
            if ( data.data.code == '1111') {
              vm.$router.push({
                path: '/401',
              });
              return
            }
            if(data.data.success){
              console.log('11111')
              console.log('上传图片',data)
              vm.$message({
                message: '上传图片成功！',
                type: 'success'
              });
            }else {
              vm.$message.error('上传图片失败！')
            }
          })
        }
      })
    },

    delImage: function (index) {
      $(".table-file").val("");
      this.dimension.results[index].pic = '';
    },

    querySearch(propertiesItem) {
        //var restaurants = this.restaurants;
        return function(queryString, cb) {
          let list =  propertiesItem.valueList;
          let results = queryString ? list.filter((v)=> v.value.toLowerCase().indexOf(queryString.toLowerCase())>-1) : list;
          
          cb(results);
        }
        
    },

    handleSelect(item) {
      return function(v) {
        item.selectModal = v.value;
      }
      // console.log(item);
    }

  },
  created() {
    window.v = this;
    //获取店铺列表
    this.getShopList();

    //获取站点列表
    this.getSiteList();

    //获取国家信息
    this.getCountry();

    //获取支付方式
    this.getPayMentMethod();

    //获取仓库地址
    this.getWareHours();

    //获取退货政策
    this.getPolicy("refundOption");

    //获取退货天数
    this.getDays();

    //获取退货方式
    this.getWay();

    //获取退货运费由谁负担
    this.getPrincipal();

    //获取折旧率
    this.getRateDepreciation();

    //获取路由传参
    this.getParams();

    //编辑草稿
    if (this.getParams()) {
      this.getDraftEdit();
    }

    //获取运输地区
    this.getShipLocal();

    //获取产品标示类型
    this.getTypeList();

    //获取货币
    this.getCurrency();

  },
  computed: {
    quote() {
      return this.generalInfo.sku;
    },
    site() {
      return this.generalInfo.site
    },
    hasAllow() {
      return this.tradeRestrictions.hasAllow;
    },
    chooseNoTran() {
      return this.nonTransportArea.chooseNoTran;
    },
    shop() {
      return this.generalInfo.shop;
    },
    productAttPop() {
      return this.productAtt.properties;
    },
    quantity() {
      return this.titleAndPrice.quantity;
    },
    inventoryWarning() {
      return this.titleAndPrice.inventoryWarning;
    },
    startPrice() {
      return this.titleAndPrice.startPrice;
    },
    reservePrice() {
      return this.titleAndPrice.reservePrice;
    },
    fixedPrice() {
      return this.titleAndPrice.fixedPrice;
    },
  },
  watch: {
    ebaySku:function(val){
      console.log('wathc',val)
      this.ebaySku = val;
    },
    shippingServiceOptionList: function () {
      let vm = this;
      //获取运输地区
      vm.returnTransTypeFn(0);
      vm.returnTransTypeFn(1);
    },
    site: function () {
      //获取产品标示类型
      this.getTypeList();

      //获取货币
      this.getCurrency();
    },
    // quantity:function(){
    //   this.titleAndPrice.quantity = (this.titleAndPrice.quantity).replace(/[^0-9]/g,'');
    // },
    // inventoryWarning:function(){
    //   this.titleAndPrice.inventoryWarning = (this.titleAndPrice.inventoryWarning).replace(/[^0-9]/g,'');
    // },
    // startPrice:function(){
    //   this.titleAndPrice.startPrice = (this.titleAndPrice.startPrice).replace(/[^0-9\.]/g,'');
    // },
    // reservePrice:function(){
    //   this.titleAndPrice.reservePrice = (this.titleAndPrice.reservePrice).replace(/[^0-9\.]/g,'');
    // },
    // fixedPrice:function(){
    //   this.titleAndPrice.fixedPrice = (this.titleAndPrice.fixedPrice).replace(/[^0-9\.]/g,'');
    // },
    returnArr: function (val) {
      this.getreturnArr = val;
    },
    internalTransReturnArr: function (val) {
      this.internalTransReturnArr1 = val//国内运输方式
    },
    inlandTransReturnArr: function (val) {
      this.inlandTransReturnArr1 = val//国际运输方式
    },
    inlandTransList: function (val) {
      this.inlandTransList = val;
      this.inlandTransListSave = val;//国际运输方式
    },
    intTransList: function (val) {
      this.intTransList = val;
    },
    shop: function (val) {
      for (let i = 0; i < this.shopList.length; i++) {
        if (val == this.shopList[i].id) {
          this.generalInfo.shopName = this.shopList[i].name;
        }
      }
    },
    productAttPop: function (val) {
      console.log("watch-productAttPro");
      this.productAtt.properties = val;
      let vm = this;
      for (let i = 0; i < vm.productAtt.properties.length; i++) {
        vm.productAtt.properties[i].selectModal = '';
        vm.productAtt.properties[i].selectChecked = [];
      }
      let _draftId = this.getParams();
      if(_draftId && vm.firstCator == vm.productAtt.firstCator){
        vm.itemProperties = [];
        if (vm.attrSave.length != 0) {
          for (var i = 0; i < vm.attrSave.length; i++) {
            var obj = vm.attrSave[i];
            var num = obj.name;
            var isExist = false;
            for (var j = 0; j < vm.productAtt.properties.length; j++) {
              var aj = vm.productAtt.properties[j];
              var n = aj.name;
              if (n == num) {
                isExist = true;
                break;
              }
            }
            if (!isExist) {
              vm.itemProperties.push(obj);
            }
          }
          // for (let ii = 0; ii < this.attrSave.length; ii++) {
          //   if (this.attrSave[ii].value.split(',') instanceof Array) {
          //     this.productAtt.properties[ii].selectChecked = this.attrSave[ii].value.split(',');
          //   }
          //   this.productAtt.properties[ii].selectModal = this.attrSave[ii].value;
          // }
        }
        if (vm.productAtt.properties.length != 0) {
          for (let ii = 0; ii < this.attrSave.length; ii++) {
            if (this.attrSave[ii].value.split(',') instanceof Array) {
              this.productAtt.properties[ii].selectChecked = this.attrSave[ii].value.split(',');
            }
            this.productAtt.properties[ii].selectModal = this.attrSave[ii].value;
          }
        }
      }else {
        vm.productAtt.goodsStateSelect= '';
        vm.itemProperties = [];
      }


    },
    quote: function () {
      this.quoteSystemSKU();
    },
    modal: function (val, newVal) {
      this.modal = val;
    },
    chooseNoTran: {
      handler: function (newVal) {
        this.nonTransportArea.chooseNoTran = newVal;
      },
      deep: true
    },
    hasAllow: function (val, newVal) {
      this.tradeRestrictions.hasAllow = val;
      // this.violateTimeFn();
      // this.violateNumFn();
      this.astrictNumFn();
      this.underCreditFn();
      // this.nonPaymentNumFn();
      // this.underBuyerFn();
      // this.underPeputationFn();
    },

  },
  // components:address
}
